Results 1 to 3 of 3
  1. #1
    Riverpaw is offline bad, but inconsistent
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Java tutorial bike example

    I tried to make the bike examples from the java tutorial work ( except for switching out a bike for a car), but whenever i try to compile, it says that there is no main method. From what I had gleaned from the tutorial, I didn't need one for a class that just sets values.
    Also, is there a special way to put code in, or am i just supposed to copy-paste?



    class Car {
    // Problem with cmd prompt saying
    //I'm not putting in a method body

    int rpm = 0;
    int speed = 0;
    int gear;

    // next three "voids" used to dertermine
    // how to change the speed, gear, and rpm values.

    void changeRpm (int newValue) {
    rpm = newValue;
    }

    void changeSpeed (int newValue) {
    speed = newValue;
    }

    void changeGear (int newValue) {
    gear = newValue;
    }

    void printStates () {
    System.out.println ("rpm:" + rpm+
    "speed:" + speed +
    "gear:" + gear);
    }
    }

    class Testdrive {
    public static void main(String[] args) {

    //create car
    Car car1 = new Car();
    /*
    * Invoking methods on this object
    */
    car1.changeGear(4);
    car1.changeSpeed(40);
    car1.changeRpm(2100);
    car1.printStates();
    }
    }

  2. #2
    Riverpaw is offline bad, but inconsistent
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: Java tutorial bike example

    Notepad is the ... IDE? that I am using.

  3. #3
    Riverpaw is offline bad, but inconsistent
    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Default Re: Java tutorial bike example

    I wrote the notes to help my parents understand, not to be accurate

Similar Threads

  1. java Tutorial
    By raj.mscking@gmail.com in forum Forum Lobby
    Replies: 2
    Last Post: 02-02-2012, 07:28 AM
  2. Making the bike pedal
    By jinglylime in forum New To Java
    Replies: 0
    Last Post: 03-22-2011, 07:53 AM
  3. Sun java tutorial in pdf?
    By makpandian in forum New To Java
    Replies: 2
    Last Post: 06-29-2009, 10:25 PM
  4. Best Tutorial for Java GUI ?
    By Ms.Ranjan in forum New To Java
    Replies: 1
    Last Post: 09-13-2008, 02:22 AM
  5. Java 5 Tutorial
    By Ganeshag777 in forum New To Java
    Replies: 1
    Last Post: 08-18-2008, 07:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •