Internal representation of a station with different tasks.
Each station has an external representation as an artifact - like a cube - with faces. The artifact is the station, the faces are the tasks.
Scanning a station's start face starts also the station in the app.
*/
classStation{
/// Name of the station, initialized as empty string
privatevarname:String=""
/// Has the station been solved? initialized as false, of course
privatevarsolved:Bool=false
/// Array of tasks of the station. As we may have different artifacts with different number of faces, an array makes most sense. Initialized as empty array.
privatevartasks:[Task]=[]
/**
Sets a new name.
- Parameter name: new name for the station
*/
publicfuncsetName(name:String){
self.name=name
}
/**
Returns the name of the station
- Returns: Returns the actual name
*/
publicfuncgetName()->String{
returnself.name
}
/**
Sets the status of the station, solved or not solved.
- Parameter solved: True, if station is solved; use false otherwise.
*/
publicfuncsetSolved(solved:Bool){
self.solved=solved
}
/**
Returns the status if the station has been solved already.
- Returns: True, if station is solved, false otherwise.
*/
publicfuncisSolved()->Bool{
returnself.solved
}
/**
Adds the given task to the internal array of tasks that belong to the station.
- Parameter task: initialized new task
*/
publicfuncaddTask(task:Task){
self.tasks.append(task)
}
/**
Returns the array of tasks.
- Returns: Array of objects of type Task
*/
publicfuncgetTasks()->[Task]{
returnself.tasks
}
/**
Returns a list of all solved tasks of the station.
- Returns: Array of tasks that has been solved already at this station.
*/
publicfuncgetSolvedTasks()->[Task]{
varsolvedTasks:[Task]=[]
fortaskintasks{
...
...
@@ -43,11 +77,19 @@ class Station {
}
returnsolvedTasks
}
///internal status if all stations has been solved; this should be calculated dynamically in a productive app.
privatestaticvarallStationsSolved=false
/**
Sets the internal status that all stations has been solved. In a productive app this should be done dynamically.
- Parameter solved: True, if all station has been solved. Use false otherwise.