Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vehicle {
- constructor(type, model, parts, fuel) {
- this.type = type;
- this.model = model;
- this.parts = parts;
- this.fuel = fuel;
- this.addQuality();
- }
- addQuality () {
- let partValues = Object.values(this.parts);
- let qualityValue = partValues[0] * partValues[1];
- this.parts.quality = qualityValue;
- return this.parts
- }
- drive (fuelLoss) {
- this.fuel -=fuelLoss
- if (this.fuel < 0) {
- this.fuel = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement