Computers and Technology

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.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 02:00, ayoismeisjuam
The word ‘play’ comes with many different interpretations and a variety of definitions. discuss some of the various meanings tied to the word play. why is the concept of play thought to be an important addition to the workplace? do some (brief) research online and give an example of how play in the workplace is being done right.
Answers: 2
image
Computers and Technology, 22.06.2019 02:10, breanastone14
3. (5 points) describe what would be printed by the code below or what error would occur. const char* cstr = "0123456"; const char* ptr = & cstr[4]; cout < < ptr[-1] < < ptr < < endl; 1 4. (5 points) theseus has been trapped in a maze with a minotaur, which is trying to capture him. each round, theseus and the minotaur move through the maze; theseus towards the exit, and the minotaur towards theseus. theseus can move in any of the four cardinal directions, or he can wait for a round to see how the minotaur moves. write code that creates a data type to represent the possible moves that theseus could make.
Answers: 3
image
Computers and Technology, 22.06.2019 09:00, 19elbatawisaly
What is one way in which tablets differ from laptops and notebooks? tablets are designed for touch-based interaction. tablets are designed to be used as desktops. tablets are designed for input via a keyboard and mouse. tablets are designed to be larger than laptops.
Answers: 1
image
Computers and Technology, 23.06.2019 15:00, med69
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a. an advanced knowledge of physics and math b. an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 2
Do you know the correct answer?
Swift code

import foundation

protocol taksperformer {

func do...

Questions in other subjects:

Konu
Mathematics, 13.01.2021 23:30