Question
IOS problem struct Lesson { var difficulty: Int = 1 } var Lesson1 = Lesson() var Lesson2 = tutorial1 Lesson2.difficulty = 2 What are the
IOS problem struct Lesson {
var difficulty: Int = 1
}
var Lesson1 = Lesson()
var Lesson2 = tutorial1
Lesson2.difficulty = 2
What are the values of lesson1.difficulty and lesson2.difficuilty?
Would this be any different if lesson was a classs? Why or why not explain with your answer.
- This code creates two classes company and address. It than creates two company instances IT and marketing.
class Address {
var fullAddress: String
var city: String
init(fullAddress: String, city: String) {
self.fullAddress = fullAddress
self.city = city
}
}
class Company {
var name: String
var address: Address
init(name: String, address: Address) {
self.name = name
self.address = address
}
}
var headquarters = Address(fullAddress: "123 Tutorial Street", city: "Appletown")
var IT = Company(name: "IT solutions", address: headquarters)
var Marketing = Company(name: "ATV Marketing",address: headquarters)
Suppose Marketing company moves to the new building across the street; you'll want to update his record like this:
brian.address.fullAddress = "148 Tutorial Street"
This compiles and runs without error. If you check the address of IT comapny now, it is also moved to the new building
print(IT.address.fullAddress)
What's going on here? How can you fix the problem?
Give a suitable solution for this.
Part b:
Write a swift class to produce invoice from customer number, customer name, customer address, date of sale, item no, item description, quantity sold, unit price of item, discount percentage and sales tax percentage. Use your own formulas for calculation of total price or tax rate etc.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started