Question
Java!!!!! plz!!!! Java !!!!! Truck class (setter methods definition) Complete the code for the class Truck. You have to implement all the mutator/setter methods for
Java!!!!! plz!!!!
Java !!!!!
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.
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. 2 i ublic class Truck { private String model: 3 private int year: 4 private String color: private double maxCapacity: 6 //If currentLoad is 0.0 the truck is empty, if equals to maxCapacity the truck is full private double currentLoad: 5 7 8 9 10 11 12 public Truck() { this. model "default model" : this. year = 2000: this.color= "default color": this. maxCapacity = 1800.0: this. currentLoad = 0.0: } 13 14 15 16 17 18 public Truck (String truckModel, int truckYear, String truckColor, double truckMaxCapacity, double truckCurrentLoad) { model truckModel: year = truckYear: color truckColor: 19 20 year = = 16 17 public Truck (String truckModel, int truckYear, String truckColor, double truckMaxCapacity, double truckCurrentLoad) { 18 model = truckModel: 19 truckYear 20 color truckColor : 21 maxCapacity = truckMaxCapacity: 22 currentLoad = truckCurrentLoad: 23 } 24 // TODO: add set methods for model, year, color, maxCapacity and currentLoad 25 // There has to be 5 methods in total here (setModel, setYear, setColor, setMaxCapacity, setCurrentLoad). 26 27 28 29 30 }Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started