Department of Computer Science and Information Technology Sarhad University, Peshawar
Name:Wasim wahid
Reg no:SU-17-01-002-123
Section:”c”
Email:wasimwahid.nba@gmail.com
Final Term Examination
Subject: IOS MAC APPLICATION DEVELOPEMENT marks:50
Semester:7th time:24 hrs
Question 1: (6)
1. Consider the following code:
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.
2. 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.
(4)
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.
Question no 2
Part 1 (8)
1. Spot the error and explain the error as well
func Exercise(_ repeat: Int, type: String) -> Int {
var output: String = “”
for _ in 0 ..< repeat {
output += "I'm doing a \(type)\n"
}
if repeat < 10 {
output += "That was easy!"
} else if repeat < 30 {
output += "That was challenging!"
} else {
output += "Phew - I need a break!"
}
return output
}
print(Exercise(repeat: 34, type: "push up"))
2.
func shareWinnings(people: Int, fairly: Bool) -> String {
var returnValue: String = “We’re going to split this…\n’
if fairly {
returnValue += “Everyone gets 1/\(people)”
} else {
returnValue +=”I get half because I deserve it.\n”
returnValue += “Everyone else can split the remainder.”
}
return returnValue
print(shareWinnings(people: 3, fairly: true))}
1) Rearrange the line of code
struct XWing {
if callSign == “Red 5”
{
return false
var callSign: String
}
{
return true
else {
}
func shouldAttackDeathStar() -> Bool
}
}
2) Rearrange the code
if number % 2 == 0 {
for number in numbers {
}
print(number)
var numbers = [1, 2, 3, 4, 5, 6]
}
} else {
print(“Skipping odd number”)
part: b
Q: Write a note on the following also give examples.
· UINavigationController
· UITabBarController
· UISplitViewController
(2)
Question no 3
1. Create a function fetchUserEmail and send the userID as parameter. Create 8 users and check the id with its email. Print the email when the id matches.
(5)
2. Create a program and give options to user to display student record.
user selects A The program should display names of 10 students,
user selects B The program should display gpa of 10 students,
user selects C The program should display name, gpa & roll no of 10 students. (use structures).
Select the student with highest gpa and display it as
The topper of class is: name with gpa of “ ”
(5)
Question 4
a) Create a program for a reader. If the reader enters page number of a book the program will show page number along with title of the page where
Page1: contents of book
Page2-4: introduction
Page4: chapter 1
Page30: chapter 2
Page31: chapter 2 swift tutorials
Page40-150: main title: tutorials and second title tutorial number (page 40-50 tutorial 1, page 51-85 tutorial 2, page 86-120 tutorial 3 & page 120-150 tutorial 4)
(main heading: “swift programming tutorials”)
(sub heading: “tutorial 1”)
(5)
b) Consider the above question of book. Print 100 copies of that book as well and set the name of the book and author name of the book as:
Book title: swift for “beginners” , book author: “paul”
(5)
Question no 5
Part a:
Implement the concept of inheritance. Create 3 classes department, telecom and software.
Department has class members: chairman (string), (string func) welcome, students(int)
Telecom has member: batches (bool)
Software has member: semester (int)
Display the following output by using above knowledge
Welcome to telecom department
Chairman of telecom department is ali shahzad
There are 300 students in telecom department
Telecom department has 5 graduate batches true
Welcome to software department
Chairman of software department is Hamza shah
There are 100 students in software department 8th semester.
(7)
Part b: (3)
1. Summarize main difference between classes and structures with help of an example?
We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.
Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.
Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.
Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.
Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.
Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.
We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.
Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.
You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.
From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.
Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.
Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.
You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.
You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.
Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.
We create perfect papers according to the guidelines.
We seamlessly edit out errors from your papers.
We thoroughly read your final draft to identify errors.
Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!
Dedication. Quality. Commitment. Punctuality
Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.
We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.
We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.
We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.
We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.