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, 23.06.2019 04:31
Type the correct answer in the box. spell all words correctly. the managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an
Answers: 1
question
Computers and Technology, 23.06.2019 12:50
Which syntax error in programming is unlikely to be highlighted by a compiler or an interpreter? a variable name misspelling a missing space a comma in place of a period a missing closing quotation mark
Answers: 1
question
Computers and Technology, 24.06.2019 09:30
What is the definition of digital literacy?
Answers: 1
question
Computers and Technology, 24.06.2019 20:30
Where is permanent data in the computer stored whenever gym starts his laptop he sees some commands in numbers appearing on the screen these instructions are being preceded by the control unit in
Answers: 1
You know the right answer?
Swift code

import foundation

protocol taksperformer {

func do...
Questions
question
English, 17.11.2020 19:50
question
Mathematics, 17.11.2020 19:50
question
English, 17.11.2020 19:50
question
Arts, 17.11.2020 19:50