gdhshwjfs
31.12.2019 •
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.
Solved
Show answers
More tips
- H Health and Medicine Want to Lose Weight? Gain Muscle without Damaging Your Health!...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
- O Other How to Choose the Best Answer to Your Question on The Grand Question ?...
- L Leisure and Entertainment History of International Women s Day: When Did the Celebration of March 8th Begin?...
- S Style and Beauty Intimate Haircut: The Reasons, Popularity, and Risks...
- A Art and Culture When Will Eurovision 2011 Take Place?...
Answers on questions: Computers and Technology
- C Computers and Technology Which of the following operations describes a good document management system?...
- C Computers and Technology 7. On a control drawing, what s indicated by the bar under the rung location for a set of relay contacts?...
- M Mathematics Which fraction is equivalent to 7 divided by 12...
- C Chemistry Which of the following pieces of glassware can be used to measure the volume of a liquid with the greatest accuracy? a. test tube b. beaker c. flask d. graduated cylinder...
- E English What is negative externality of a cell phone?...
- B Biology which of the viruses listed below attacks the host cell by merging its membrane with that of the host cell and releasing its contents into the host cell cytoplasm?...
- C Computers and Technology Data that can be used to identity a single individual is known as...
- M Mathematics Factor completely: 12x^5 + 6x^3 + 8x^2 a- prime b- 2(6x^5+3x^3+4x^2) c- 2x(6x^4+6x^2+4x) d- 2x^2(6x^3+3x+4)...
- H History Who discovered the first and largest asteroid...
- H History Which ruler united the feudal kingdoms of germany under his reign...
Ответ: