importFoundation/*
SetAlarm challenge function
@param currentlyEmployed: Bool indicating if we are currently employed.
@param onVacation: Bool indicating if we are currently on vacation.
@return Bool indicating if we need to set our alarm. Only true if both employed and not on vacation.
*/funcsetAlarm(currentlyEmployed:Bool,onVacation:Bool)->Bool{return(currentlyEmployed&&!onVacation)}// run with all examplesprint("Ex1 setAlarm(true,true) -> false: ",setAlarm(currentlyEmployed:true,onVacation:true))print("Ex2 setAlarm(false,true) -> false: ",setAlarm(currentlyEmployed:false,onVacation:true))print("Ex3 setAlarm(false,false) -> false: ",setAlarm(currentlyEmployed:false,onVacation:false))print("Ex4 setAlarm(true,false) -> true: ",setAlarm(currentlyEmployed:true,onVacation:false))// not exactly proper test suite, but you get the idea.print("Passed all tests: ",(!setAlarm(currentlyEmployed:true,onVacation:true)&&!setAlarm(currentlyEmployed:false,onVacation:true)&&!setAlarm(currentlyEmployed:false,onVacation:false)&&setAlarm(currentlyEmployed:true,onVacation:false)))
Outputs the following:
Ex1 setAlarm(true,true) -> false: false
Ex2 setAlarm(false,true) -> false: false
Ex3 setAlarm(false,false) -> false: false
Ex4 setAlarm(true,false) -> true: true
Passed all tests: true
Program ended with exit code: 0
Overkill with all the printouts, but hey, why not?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Swift version:
Outputs the following:
Overkill with all the printouts, but hey, why not?