mirror of https://github.com/01-edu/public.git
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.
48 lines
633 B
48 lines
633 B
6 years ago
|
## Fix the Main
|
||
6 years ago
|
|
||
6 years ago
|
### Instructions
|
||
6 years ago
|
|
||
5 years ago
|
Fix the following program.
|
||
6 years ago
|
|
||
5 years ago
|
### Program to fix
|
||
6 years ago
|
|
||
|
```go
|
||
6 years ago
|
package piscine
|
||
|
|
||
5 years ago
|
func PrintStr(s string) {
|
||
|
for _, r := range s {
|
||
5 years ago
|
z01.PrintRune(r)
|
||
6 years ago
|
}
|
||
|
}
|
||
|
|
||
|
func CloseDoor(ptrDoor *Door) bool {
|
||
5 years ago
|
PrintStr("Door Closing...")
|
||
6 years ago
|
state = CLOSE
|
||
|
return true
|
||
|
}
|
||
|
|
||
|
func IsDoorOpen(Door Door) {
|
||
5 years ago
|
PrintStr("is the Door opened ?")
|
||
6 years ago
|
return Door.state = OPEN
|
||
|
}
|
||
|
|
||
|
func IsDoorClose(ptrDoor *Door) bool {
|
||
5 years ago
|
PrintStr("is the Door closed ?")
|
||
6 years ago
|
}
|
||
|
|
||
|
func main() {
|
||
|
door := &Door{}
|
||
|
|
||
|
OpenDoor(door)
|
||
|
if IsDoorClose(door) {
|
||
|
OpenDoor(door)
|
||
|
}
|
||
|
if IsDoorOpen(door) {
|
||
|
CloseDoor(door)
|
||
|
}
|
||
|
if door.state == OPEN {
|
||
|
CloseDoor(door)
|
||
|
}
|
||
|
}
|
||
5 years ago
|
```
|