English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Can someone help me code this car class in Java?
The car class should have the following unique private instance variables: myColor, MyEngine that stores its engine size in liters, mySuspension - e.g., firm, soft, touring,etc., and myTires - e.g., regular, wide, low profile, etc.

a sample output would read: your cool red sports car has a 3.2 liter engine, firm suspension and low profile tires.

Thank you

2007-03-22 12:13:01 · 2 answers · asked by jumba 1 in Computers & Internet Programming & Design

2 answers

public class Car
{
private double myEngine;
private String myColor;
private String mySuspension;
private String myTiers;

public Car(double engineSize, String color, String suspension, String tireSize)
{
myEngine = engineSize;
myColor = color;
mySuspension = suspension;
myTiers = tireSize;
}

public double getEngineSize( )
{
return myEngine;
}

public String getColor( )
{
return myColor;
}

public String getSuspension( )
{
return mySuspension;
}

public String getTireSize( )
{
return myTires;
}
}

2007-03-22 13:35:46 · answer #1 · answered by Silver_Sword 3 · 0 1

You should probably try to pay closer attention to your instructor and read the textbook - you will have a very hard time passing a Java class if you can't even make a class from those specifications.

2007-03-22 19:28:18 · answer #2 · answered by Rex M 6 · 0 2

fedest.com, questions and answers