Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!!!!

image text in transcribed

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions

Question

connected with any particular community cause?

Answered: 1 week ago

Question

2 What supply is and what affects it.

Answered: 1 week ago

Question

3 How supply and demand together determine market equilibrium.

Answered: 1 week ago