-
Notifications
You must be signed in to change notification settings - Fork 761
/
Copy pathclasses.js
107 lines (77 loc) · 3.22 KB
/
classes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
Once you complete a problem, refresh ./classes.html in your browser and check to see if the problem's test(s) are passing.
Passed tests will be indicated by a green circle.
Failed tests will be indicated by a red X.
You can refresh the page at any time to re-run all the tests.
Classes are a tool for building similar objects over and over again.
They are a construct that helps your organize your code.
Let's work with some employees at a company.
You work for Widget Co. They have hundreds of employees.
*/
////////// PROBLEM 1 //////////
/*
Make a class to help us build all of the employees.
Each employee has the following properties:
- first_name
- last_name
- email
- age
Each employee has the following methods:
- makeWidget
- This returns a string equal to the employees first name + last name + the word widget
- Example: "Dave Smith Widget"
Call your class Employee and receive all the data in the constructor in the order listed above.
*/
//Code Here
////////// PROBLEM 2 //////////
/*
Next, make a manager for Widget Co.
The manager has all the same properties as an Employee. Copy the Employee class and rename it Manager.
Each manager has the following additional properties:
- reports (other employees) that defaults to an empty array
Each manager has the following additional methods:
- hire (employee)
- Accepts a new employee as a parameter and pushes it to their list of reports.
- fire (index)
- Fire removes employees from their list of reports at the given index
Call your new class Manager
*/
//Code Here
////////// PROBLEM 3 //////////
/*
Managers for Widget Co. get promoted when they get more employees, and get a bonus when they fire employees.
Progressive managers have all the same properties as managers. Copy the Manager class and rename
it to ProgressiveManager. Add the following additional properties:
- title - default 'Not a manager'
- bonus - default 0
When employees are hired or fired, the manager's title should be updated based on the number of reports.
0 reports : Not a manager
1-3 reports : Barely Manager
4-10 reports : Mostly Manager
11-50 reports : Manager
51-100 reports : Manager Plus
101+ reports : Bestest Manager
Everytime they fire an employee they get $100 added to their bonus.
Call your new class ProgressiveManager
*/
//Code Here
////////// PROBLEM 4 - Black Diamond //////////
/*
Widget Co has a factory that makes widgets.
Factories have Machines.
Make a Machine class that takes in no parameters
A Machine has the following properties:
- widgets_made_count - default 0
- wear_and_tear_count - default 0
- needs_reboot - default false
A Machine has the following methods:
- makeWidgets
- This function takes in a number and increases widgets_made_count by that amount
- It also increases wear_and_tear_count by 1 for every 50
- fixMachine
- This function sets needs_reboot to true
- reboot
- This function returns an anonymous function that is called when the machine is done rebooting
- The anonymous function should decrease wear_and_tear_count by 10, and set needs_reboot to false
*/
//Code Here