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 15:00
Hyperactive media sales has 10 windows 7 laptop computers used by sales-people in the organization. each laptop computer has several customized applications that are used during the sales process as well as customer relationship management software. all of the applications on the laptops are difficult to configure and have large data files. if all of the laptops have current hardware, what is the easiest way to install windows 10 on them?
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
This graph compares the total cost of attending educational institutions in texas. the graph demonstrates that the cost at private and public technical schools greatly varies.
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
What are some ways to use a range name in a formula? check all that apply. in the defined names group, click use in formula, and then select the desired name. begin typing the name in the formula, select a name from the autocomplete list, and use the arrow keys and tab key to enter the name in the formula. begin typing the formula, and then click and drag with the mouse to select the cells to include in the formula. right-click one of the cells in the range. click formula options, and use the dialog box to add the name.
Answers: 1
question
Computers and Technology, 23.06.2019 03:00
What are the different parts of computer
Answers: 2
You know the right answer?
Swift code

import foundation

protocol taksperformer {

func do...
Questions
question
Mathematics, 02.10.2019 12:00
question
Spanish, 02.10.2019 12:00
question
Mathematics, 02.10.2019 12:00
Questions on the website: 13722362