You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
## Fix the Main
|
|
|
|
|
|
|
|
### Instructions
|
|
|
|
|
|
|
|
Write and fix the folloing functions.
|
|
|
|
|
|
|
|
### Expected functions
|
|
|
|
|
|
|
|
```go
|
|
|
|
func PrintStr(str string) {
|
|
|
|
arrayRune := []rune(str)
|
|
|
|
for _, s := range arrayRune {
|
|
|
|
z01.PrintRune(s)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func CloseDoor(ptrDoor *Door) bool {
|
|
|
|
PrintStr("Door closing...")
|
|
|
|
state = CLOSE
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsDoorOpen(Door Door) {
|
|
|
|
PrintStr("Door is open ?")
|
|
|
|
return Door.state = OPEN
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsDoorClose(ptrDoor *Door) bool {
|
|
|
|
PrintStr("Door is close ?")
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
|
|
|
Here is a possible [program](TODO-LINK) to test your function :
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
door := &Door{}
|
|
|
|
|
|
|
|
OpenDoor(door)
|
|
|
|
if IsDoorClose(door) {
|
|
|
|
OpenDoor(door)
|
|
|
|
}
|
|
|
|
if IsDoorOpen(door) {
|
|
|
|
CloseDoor(door)
|
|
|
|
}
|
|
|
|
if door.state == OPEN {
|
|
|
|
CloseDoor(door)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
And its output :
|
|
|
|
|
|
|
|
```console
|
|
|
|
student@ubuntu:~/piscine/test$ go build
|
|
|
|
student@ubuntu:~/piscine/test$ ./test
|
|
|
|
Door Opening...
|
|
|
|
Door is close ?
|
|
|
|
Door is open ?
|
|
|
|
Door closing...
|
|
|
|
student@ubuntu:~/piscine/test$
|
|
|
|
```
|