Question: SWIFT 4- Complete the below code by adding print statements to each method, run each method and provide a print statement of each output. Ensure
SWIFT
4- Complete the below code by adding print statements to each method, run each method and provide a print statement of each output. Ensure you create new objects too run the methods. struct Car { var make: String var year: Int var color: Color var topSpeed: Int func startEngine() {...} func drive() {} func park() {} let firstCar = Car(make: "Honda", year: 2010, color: blue, topSpeed: 120) let secondCar = Car(make: "Ford", year: 2013, color: black, topSpeed: 125) firstCar.startEngine() firstCar.drive()" a. What will the values be for each of the variables? 6- Without realising we used an item could the memberwise initializer. Swift creates a special initializer, called a memberwise initializer, that includes all properties of a structure. The memberwise initializer allows you to set initial values for each property of the new instance. To access these values similar to java you place the instance name then a dot, then the variable name. a. Print the cars colour b. Print the cars make 4- Complete the below code by adding print statements to each method, run each method and provide a print statement of each output. Ensure you create new objects too run the methods. struct Car { var make: String var year: Int var color: Color var topSpeed: Int func startEngine() {...} func drive() {} func park() {} let firstCar = Car(make: "Honda", year: 2010, color: blue, topSpeed: 120) let secondCar = Car(make: "Ford", year: 2013, color: black, topSpeed: 125) firstCar.startEngine() firstCar.drive()" a. What will the values be for each of the variables? 6- Without realising we used an item could the memberwise initializer. Swift creates a special initializer, called a memberwise initializer, that includes all properties of a structure. The memberwise initializer allows you to set initial values for each property of the new instance. To access these values similar to java you place the instance name then a dot, then the variable name. a. Print the cars colour b. Print the cars make
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
