Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

  1. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

4. I give a fair hearing to fellow members ideas.

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago