[nbusers] Help needed - beginner level , does not compile.

  • From: "siddhubhai" < >
  • To:
  • Subject: [nbusers] Help needed - beginner level , does not compile.
  • Date: Wed, 24 Oct 2012 18:29:26 -0400

package Bicycledemo;

    class Bicycle {
    
    int cadence = 0;
    int speed = 0;
    int gear = 1;

    void changeCadence(int newValue) {
         cadence = newValue;
    }

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

    void speedUp(int increment) {
         speed = speed + increment;   
    }

    void applyBrakes(int decrement) {
         speed = speed - decrement;
    }

    void printStates() {
         System.out.println("cadence:" +
             cadence + " speed:" + 
             speed + " gear:" + gear);
    }
   }
  
public class BicycleDemo {
    public static  void main(String[] args) {
 
        // Create two different
        // Bicycle objects
        Bicycle bike1 = new Bicycle() ;
        Bicycle bike2 = new Bicycle();
 
        // Invoke methods on
        // those objects
        bike1.changeCadence(50);
        bike1.speedUp(10);
        bike1.changeGear(2);
        bike1.printStates();
 
        bike2.changeCadence(50);
        bike2.speedUp(10);
        bike2.changeGear(2);
        bike2.changeCadence(40);
        bike2.speedUp(10);
        bike2.changeGear(3);
        bike2.printStates();
    }
}






[nbusers] Help needed - beginner level , does not compile.

siddhubhai 10/24/2012

[nbusers] Re: Help needed - beginner level , does not compile.

trhouse 10/24/2012

[nbusers] Help needed - beginner level , does not compile.

siddhubhai 10/25/2012

[nbusers] Help needed - beginner level , does not compile.

siddhubhai 10/25/2012

[nbusers] Help needed - beginner level , does not compile.

siddhubhai 10/25/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close