View Single Post
Old 07-27-2012, 03:40 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,651
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by dannyboi View Post
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();
}
What are you doing with the curly braces there? Whilst you can open and close braces randomly in Java, the main does have a closing brace which places the calls on bike1 and bike2 later within the class body which isn't applicable.

Are these both supposed to be combined in the class main? If so, it is missing a closing brace somewhere, else it's still missing a closing brace but I don't know where it would go. Nested classes also cannot have a main method.

I'm also trying to figure out if the properties and the methods actually belong to the Bicycle (which they appear to) or if they belong to the main. The current code has them in main.
PHP Code:
public class Main{
    class 
Bicycle {
    } 
Fou-Lu is offline   Reply With Quote