This is my project and I have the code below.....Create a class that simulates the functionality of a simple car. You can do simple things like drive, add gas and honk the horn. Simple text messages are displayed on the screen for feedback when appropriate and ALWAYS include the make and model of the car. The car’s oil should be changed every 5,000 miles.

•   Provide appropriate names and data types for each of the private instance variables: a String for the make and model (e.g. “Honda Civic”), an integer for the odometer, an integer for the mileage of the next oil change, a double for the gallons of gas in the tank, a double for miles per gallon, a final double of the gas tank capacity (12.5) that never changes and a String for the make of the vehicle.  (5 pts)
•   public Car () - this default constructor sets the miles per gallon to 22.7, the make to “Generic Car”, fills the tank, sets the odometer to zero and sets the next oil change reminder. (5 pts)
•   public Car (String model, double mpg) - this constructor does everything the default constructor does and sets the make/model and miles per gallon to the provided amounts. (5 pts)
•   public int checkOdometer ( ) - return the current mileage. Do not print a message. (5 pts)
•   public double checkGasGauge ( ) - return the amount of gas in the tank. Do not print a message. (5 pts)
•   public void honkHorn ( ) - print a message more creative than "beep beep!" (5 pts) 
•   public void addGas (double g) – add the provided amount of gas to the tank.  Print a message showing the amount of gas in the tank after the fill up.  Assume the passed value is a positive number and that it will not overfill the tank. (5 pts)
•   public void drive (int miles) – Modify the odometer and gas tank to reflect the miles driven and the gas burned.  The odometer will increase and the amount of gas will decrease based on the miles driven and the car’s miles per gallon rating.  Assume the parameter is a positive integer and will not cause the car to run out of gas.  (10 pts)
•   public void changeOil ( ) - set the oil change reminder to 5,000 miles from the current odometer reading. Print an appropriate message that the oil was changed and when it should be next changed. (5 pts) 
•   public void checkOil ( ) – Print one of two options depending on how the odometer compares to the next oil change reminder: 1) “It is time to change the oil”, or 2) “Oil is OK, no need to change.” See sample output below. (5 pts) 

Challenge Requirements
The following should only be attempted after all of the other requirements have been completed.
•   Modify the void drive (int miles) method to check for three possibilities: 1) print a warning message if the parameter is negative and do not update the instance of the Car; 2) print a warning message if the car runs out of gas during the trip and the miles driven.  Only add the actual miles driven before running out of gas and update the gas tank. Or 3) modify the odometer and amount of gas to reflect the miles driven and print an appropriate message. (5 pts)
•   Modify the void addGas (double g) method to check for three possibilities, 1) provide a warning message if the number of gallons results in the tank overflowing but still fill the tank; 2) provide a warning message if the value is negative and do not modify the gas tank; or 3) add the provided amount of gallons to the tank. For all conditions, print a message showing the amount of gas in the tank after the fill up. See sample output below.  (5 pts)
•   Add a boolean instance variable that monitors if the engine is on or off. Create new methods: void startEngine( ) and void stopEngine( ) that set the boolean variable and print an appropriate message. Modify existing methods with a warning message if the car is, or is not, running and do not perform the requested action. For example, the car must be running to drive. The car must be turned off to add gas, check oil, or change the oil. (10 pts)

--

public class Car
{
    // instance variables 
    private String model ;
    private int odometer, oilchng;
    private double gallons, mpg, miles;

    private final double TANKCAP = 12.5;

    public Car()
    {
        this("Generic Car", 22.7);

    }

    public Car(String model, double mpg)
    {
        make = model;
        odometer = 0;
        miles = 0.0;
        oilchng = 5000;
        this.mpg = mpg;
        gallons = 12.5;
    }

    public int checkOdometer()
    {
        return odometer;
    }

    public double checkGasGauge()
    {
        return gallons;
    }

    public void honkHorn()
    {
        System.out.println("Honk, Honk");
    }

    public void addGas(double g)
    {

    }

    public void drive(int miles)
    {

        odometer = odometer+miles;
    }

}

Need help... im lost help asap

For “Honda Civic”, "Honda" is the make (who made it); "Civic" is the model (what kind of car it is).

That should help just a little. :icon_mrgreen:

Looks like you're stuck on the 'addGas' method.

What would it take to "add the provided amount of gas to the tank. Print a message showing the amount of gas in the tank after the fill up."?

(This is made easier by the fact that you can make this assumption: "Assume the passed value is a positive number and that it will not overfill the tank.")

I am so far behind I have no idea what I am doing. this was due oct 6.. but my roomate stepped and cracked my screen so I fell very far behind... I have no idea where to even start anymore...

Looks like you're stuck on the 'addGas' method. What would it take to "add the provided amount of gas to the tank. Print a message showing the amount of gas in the tank after the fill up."? (This is made easier by the fact that you can make this assumption: "Assume the passed value is a positive number and that it will not overfill the tank."

Take a deep breath. Try to relax. You'll just "spin your wheels" if you try to hard.

The best way to figure out where to start, you need to know where you are. I think it would be helpful to go through the bullet points you posted, and determine which one's you've done. Of the basic (non-"Challenge") bullet points, it looks like you've done most of them. I think you have about three remaining. (And it's not the last three!)

It will seem like a waste of time to review all the bullet points of the assignment. But it will be good for you. It will help you remember what you were doing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.