Question: Java !!!!!!!!! I try it, but it still shows me have some bugs, which leads me can not pass the cases. Truck class (setter methods

Java !!!!!!!!! I try it, but it still shows me have some bugs, which leads me can not pass the cases.

Java !!!!!!!!! I try it, but it still shows me have some

bugs, which leads me can not pass the cases. Truck class (setter

methods definition) Complete the code for the class Truck. You have to

Truck class (setter methods definition) Complete the code for the class Truck. You have to implement all the mutator/setter methods for each of these 5 attributes. Assume that the accessor/getter methods are already implemented. Make sure that currentLoad will never exceed maxCapacity. If it does, set currentLoad to maxCapacity. Also, make sure that the maxCapacity and currentLoad cannot be set as negative, it that happens set the value to 0. More instructions on how to implement the missing parts of this class are provided in the code below. 1 public class Truck { 2 private String model: 3 private int year: 4 private String color: 5 private double maxCapacity: 6 //If currentLoad is 0.0 the truck is empty, if equals to maxCapacity the truck is full 7 private double currentLoad; 8 9 public Truck() { 10 this. model "default model" : 11 this.year = 2000; 12 this.color= "default color": 13 this. maxCapacity = 1800.0: 14 this. currentLoad = 0.0; 15 } 16 17 public Truck (String truckModel, int truckYear, String truckColor, double truckMaxCapacity, double truckCurrentLoad) { 18 model = truck Model: 19 year = truckYear: 20 color = truckColor: 21 maxCapacity = truckMaxCapacity: 22 currentLoad = truckCurrentLoad; 23 } 25 // There has to be 5 methods in total here (setModel, setYear, setColor, setMaxCapacity, setCurrentLoad). // setter methods public void setModel (String truckModel) { this. model=truckModel: } 26 27 28 29 30 31 32 33 34 35 36 37 38 public void setYear (int truckYear) { this.year=truckYear: } public void setColor (String truckColor) { this.color=truckColor: } public void setMaxCapacity (double truckMaxCapacity) 39 40 41 42 43 44 45 46 47 48 49 this. MaxCapacity=truckMaxCapacity: } 50 51 52 53 54 55 56 public void setCurrentLoad(double truckCurrentLoad) { if (truckCurrentLoad(O) this. currentLoad=0.0: else if (truckCurrentLoad>this. MaxCapacity) this.currentLoad=this.maxCapacity: else this. currentLoad=truckCurrentLoad: } 57 58 59 } Submit * Your solution passed 5 out of 6 cases! Feedback Passed [hidden case]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!