//Here is my simple class for MyCar

   public class MyCar
            private int odometer;
            private int speed;
            private int gear;

            public MyCar() //send values to member variables in this default constructor
                odometer = 0;
                speed = 0;
                gear = 0.0;

            public MyCar(int od, int sp, int gr) //constructor passing values;
                odometer = od;
                speed = sp;
                gear = gr;

             public int getOdometer() //accessors have no parameters
                return odometer;

            public int getSpeed()
                return speed;
            public int getGear()
                return gear;

            public void changeOdometer(int od)
                odometer = odometer + od;

            public void changeSpeed(int sp)
                spead = sp;
            public void changeGear(int gr)
                gr = gr;

What I need to do is write Java code for a Parts interface for MyCar. The signatures should be named get and set. Let odometer, speed, and gear classes implement the interface. Let the generic class that uses the interface be named MyCar. Somebody please help I am totally lost with this interface stuff.

6 Years
Discussion Span
Last Post by JamesCherrill

That's too big a question to expect anyone to write a complete explanation just for you, so let's do it in easy stages.
First, get comfortable with the idea of interfaces. Read
followed immediately by
then try the first part of your exercise:

a Parts interface for MyCar. The signatures should be named get and set

Come back here with any specific questions or problems, and post all the code you have written for your Part interface

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.