Question: Answer this question based on the code listing given below. The lines of code with the following code description are shuffled and listed. In the
Answer this question based on the code listing given below. The lines of code with the following code description are shuffled and listed. In the boxes at the left-hand side, write the proper line number that should go with the line of code given next so that the entire listing is in accordance with the code description given.
Code description:
This code makes use of optional binding to test if a variable contains a unit code. The code sets up a class containing a method that carries out this test.
Only one method is created for this class. The first thing that occurs in this method is that the optional is declared and assigned a value. The value assigned is the unit code.
After the above, the code for the test then follows. The code first checks if the optional declared contains a unit code. If the optional does contain a unit code, a constant is assigned that unit code and a message is printed to the apps GUI about what the unit code of the unit is.
The second part of the test is: if no unit code is stored in the optional, a message is printed to the apps GUI that a valid unit code is not available.
|
| if let isCodeStored = unitCode { | ||
|
| } // end method | ||
|
| print("No valid unit code") | ||
|
| func unitCodeTest () { | ||
|
| } // end class | ||
|
| print("Unit code is \(isCodeStored)") | ||
|
| class ITcourse { | ||
|
| } // end if | ||
|
| var unitCode:String? = "NIT6120" | ||
| } else { |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
