Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me fix the wrong code and complete this assignment! public class BigRig{ //A BigRig needs to have a private double variables height and

Please help me fix the wrong code and complete this assignment!

public class BigRig{

//A BigRig needs to have a private double variables height and weight.

private double height;

private double weight;

//Create a constructor which takes in loadCapacity and height values.

public BigRig(float loadCapacity,double height){

this.loadCapacity = loadCapacity;

this.height = height;

//A child class ALWAYS calls its parent constructor. So, when BigRig calls

//the Truck constructor it should use the tireCount to 18.

}

//Create a non-static getter method for height.

public double getHeight(){

this.height = height;

}

//Create a non-static getter and setter for the weight variable.

public void setWeight(double weight){

this.weight = weight;

}

public double getWeight(){

return weight;

}

//Create a method called canDriveThru which takes in the height of some potential driving

//path and returns true/false depending on if the BigRig can drive through it or not.

//(Hint: compare height of drive thru parameter to height of truck.)

static boolean canDriveThru(double thru) {

if(height < thru){

true;//some code here

}else(height >= thru){

false;//some code here

}

}

//Create a toString method which will print out (in a user-friendly manner) ALL the values

//describing a BigRig object.

public String toString(){

String output = "The weight is " + weight + "." + " ";

output += "The height is " + hight + "." + " ";

output += Truck.describe() + " ";

return output;

}

}

//Create a TruckTestDrive class with a main method. In the main method create a BigRig

//object. Print out the BigRig object using the toString method.

class TruckTestDrive{

public static void main(String[] args) {

B = B.BigRig(40,100);

System.out.println(B.toString());

}

}

//Create a double mcDonalds with the height of its drive thru. Test to see if your BigRig

//can drive through and get food from McDonald's!

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

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions