subject

Swift code

import foundation

protocol taksperformer {

func doathing()

}

class employee: taksperformer {

let name: string

var boss: boss?

init(name: string) {

self. name = name

}

func doathing() {

print("\(name) is doing a thing")

}

}

class boss {

var employee: employee

let name: string

init(name: string, employee: employee) {

self. name = name

self. employee = employee

employee. boss = self

}

func actlikeaboss() {

employee. doathing()

}

}

// 1)

// a) what is wrong with the current implementation of boss and employee, why is it wrong, and how can we demonstrate that there is an issue?

//

// b) what pattern discussed in class does the boss - employee relationship remind you of? give an example of the discussed pattern.

//

// c) create a person class that has the following property:

// let name: string

// now have employee and boss inherit from person

//

// d) you realize that there are speciffic tasks you would like an employee to perform. all tasks look like this:

// func makecoffe(_ name: string) {

// print("\(name) made coffe")

// }

//

// func writereport(_ name: string) {

// print("\(name) wrote a report")

// }

// modify boss, employee and taskperformer in a way that a boss can be instantiated with the following constructor:

// boss(name: "bossman", employee: anemployee, tasks: [makecoffe, writereport])

// the employee instance should perform the tasks.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:30
At an open or uncontrolled intersection, yield if a. the cross road has more lanes than yours b. the cross road has fewer land than yours c. you’re on a state highway and the cross road is a secondary road d. do you have three or more passengers in your vehicle
Answers: 2
question
Computers and Technology, 23.06.2019 18:30
How often does colleges update the cost of attendance on their website? . a)every two years b) every four years c) every year d) every semester
Answers: 1
question
Computers and Technology, 24.06.2019 00:40
Use a software program or a graphing utility with matrix capabilities to solve the system of linear equations using an inverse matrix. x1 + 2x2 − x3 + 3x4 − x5 = 6 x1 − 3x2 + x3 + 2x4 − x5 = −6 2x1 + x2 + x3 − 3x4 + x5 = 3 x1 − x2 + 2x3 + x4 − x5 = −3 2x1 + x2 − x3 + 2x4 + x5 = 5
Answers: 3
question
Computers and Technology, 24.06.2019 17:00
Following are uses of spreadsheets. for each use, choose whether the use is a business use, consumer use, or student use. family budget: sales data: recording research data for science class:
Answers: 2
You know the right answer?
Swift code

import foundation

protocol taksperformer {

func do...
Questions
question
English, 30.06.2019 17:30
question
Mathematics, 30.06.2019 17:30
Questions on the website: 13722362