-
Notifications
You must be signed in to change notification settings - Fork 3k
/
index.js
166 lines (140 loc) Β· 6.64 KB
/
index.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
EXAMPLE TASK:
- Write an Airplane class whose constructor initializes `name` from an argument.
- All airplanes built with Airplane should initialize with an `isFlying` property of false.
- Give airplanes the ability to `.takeOff()` and `.land()`:
+ If a plane takes off, its `isFlying` property gets set to true.
+ If a plane lands, its `isFlying` property gets set to false.
*/
// EXAMPLE SOLUTION CODE:
class Airplane {
constructor(name) {
this.name = name;
this.isFlying = false;
}
takeOff() {
this.isFlying = true;
}
land() {
this.isFlying = false;
}
}
/*
// π COMPLETE YOUR WORK BELOW π
// π COMPLETE YOUR WORK BELOW π
// π COMPLETE YOUR WORK BELOW π
*/
/* ββ NOTE: PLEASE READ TASK INSTRUCTIONS CAREFULLY TO KNOW WHEN TO USE OBJECT AS CONSTRUCTOR ARGUMENT. TESTS WILL NOT PASS IF USED WHEN NOT INSTRUCTED. ββ */
/*
TASK 1
- Write a Person class whose constructor initializes `name` and `age` from 2 arguments.
- All instances of Person should also initialize with an empty `stomach` array.
- Give instances of Person the ability to `.eat("someFood")`:
+ When eating an edible, it should be pushed into the `stomach`.
+ The `eat` method should have no effect if there are 10 items in the `stomach`.
- Give instances of Person the ability to `.poop()`:
+ When an instance poops, its `stomach` should empty.
- Give instances of Person a method `.toString()`:
+ It should return a string with `name` and `age`. Example: "Mary, 50"
*/
class Person {
}
/*
TASK 2
- Write a Car class whose constructor initializes `model` and `milesPerGallon`, from 2 arguments.
- All instances built with Car:
+ should initialize with a `tank` at 0
+ should initialize with an `odometer` at 0
- Give cars the ability to get fueled with a `.fill(gallons)` method. Add the gallons to `tank`.
- Give cars ability to `.drive(distance)`. The distance driven:
+ Should cause the `odometer` to go up.
+ Should cause the the `tank` to go down taking `milesPerGallon` into account.
- A car which runs out of `fuel` while driving can't drive any more distance:
+ The `drive` method should return a string "I ran out of fuel at x miles!" x being `odometer`.
*/
class Car {
}
/*
TASK 3
- Write a Lambdasian class.
- Its constructor takes a single argument - an object with the following keys:
+ name
+ age
+ location
- Its constructor should initialize `name`, `age` and `location` properties on the instance.
- Instances of Lambdasian should be able to `.speak()`:
+ Speaking should return a phrase `Hello my name is {name}, I am from {location}`.
+ {name} and {location} of course come from the instance's own properties.
*/
class Lambdasian {
}
/*
TASK 4
- Write an Instructor class extending Lambdasian.
- Its constructor takes a single argument - an object with the following keys:
+ All the keys used to initialize instances of Lambdasian.
+ `specialty`: what the instance of Instructor is good at, i.e. 'redux'
+ `favLanguage`: i.e. 'JavaScript, Python, Elm etc.'
+ `catchPhrase`: i.e. `Don't forget the homies`.
- The constructor calls the parent constructor passing it what it needs.
- The constructor should also initialize `specialty`, `favLanguage` and `catchPhrase` properties on the instance.
- Instructor instances have the following methods:
+ `demo` receives a `subject` string as an argument and returns the phrase 'Today we are learning about {subject}' where subject is the param passed in.
+ `grade` receives a `student` object and a `subject` string as arguments and returns '{student.name} receives a perfect score on {subject}'
*/
class Instructor {
}
/*
TASK 5
- Write a Student class extending Lambdasian.
- Its constructor takes a single argument - an object with the following keys:
+ All the keys used to initialize instances of Lambdasian.
+ `previousBackground` i.e. what the Student used to do before BloomTech
+ `className` i.e. CS132
+ `favSubjects`. i.e. an array of the student's favorite subjects ['HTML', 'CSS', 'JS']
- The constructor calls the parent constructor passing to it what it needs.
- The constructor should also initialize `previousBackground`, `className` and `favSubjects` properties on the instance.
- Student instances have the following methods:
+ `listSubjects` a method that returns all of the student's favSubjects in a single string: `Loving HTML, CSS, JS!`.
+ `PRAssignment` a method that receives a subject as an argument and returns `student.name has submitted a PR for {subject}`
+ `sprintChallenge` similar to PRAssignment but returns `student.name has begun sprint challenge on {subject}`
*/
class Student {
}
/*
TASK 6
- Write a ProjectManager class extending Instructor.
- Its constructor takes a single argument - an object with the following keys:
+ All the keys used to initialize instances of Instructor.
+ `gradClassName`: i.e. CS1
+ `favInstructor`: i.e. Sean
- Its constructor calls the parent constructor passing to it what it needs.
- The constructor should also initialize `gradClassName` and `favInstructor` properties on the instance.
- ProjectManager instances have the following methods:
+ `standUp` a method that takes in a slack channel and returns `{name} announces to {channel}, @channel standy times!`
+ `debugsCode` a method that takes in a student object and a subject and returns `{name} debugs {student.name}'s code on {subject}`
*/
class ProjectManager {
}
/*
STRETCH PROBLEM (no tests!)
- Extend the functionality of the Student by adding a prop called grade and setting it equal to a number between 1-100.
- Now that our students have a grade build out a method on the Instructor (this will be used by _BOTH_ instructors and PM's) that will randomly add or subtract points to a student's grade. _Math.random_ will help.
- Add a graduate method to a student.
+ This method, when called, will check the grade of the student and see if they're ready to graduate from BloomTech
+ If the student's grade is above a 70% let them graduate! Otherwise go back to grading their assignments to increase their score.
*/
//End of Challenge
/* ππππππππππ Please do not modify anything below this line ππππππππππ */
function foo(){
return 'bar';
}
module.exports = {
foo,
Person,
Car,
Lambdasian,
Instructor,
Student,
ProjectManager
}