Results 1 to 6 of 6

Thread: need help

  1. #1
    JAVA03 is offline Member
    Join Date
    Nov 2010
    Posts
    15
    Rep Power
    0

    Default need help

    please check this code it is compling but giving run time error


    Java Code:
    public class Bicycle{
    	
        private int cadence;
        private int gear;
        private int speed;
    	
        private int id;
        
        private static int numberOfBicycles = 0;
    
    	
        public Bicycle(int startCadence, int startSpeed, int startGear){
            gear = startGear;
            cadence = startCadence;
            speed = startSpeed;
    
            id = ++numberOfBicycles;
        }
    
        public int getID() {
            return id;
        }
    
        public static int getNumberOfBicycles() {
            return numberOfBicycles;
        }
    
        public int getCadence(){
            return cadence;
        }
    	
        public void setCadence(int newValue){
            cadence = newValue;
        }
    	
        public int getGear(){
        return gear;
        }
    	
        public void setGear(int newValue){
            gear = newValue;
        }
    	
        public int getSpeed(){
            return speed;
        }
    	
        public void applyBrake(int decrement){
            speed -= decrement;
        }
    	
        public void speedUp(int increment){
            speed += increment;
        }
    	
    }
    what is the problem with it please help me
    Last edited by Eranga; 11-14-2010 at 01:41 AM. Reason: code tags added

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by JAVA03 View Post
    please check this code it is compling but giving run time error
    Is it our job now to guess what the runtime error was?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    javaman1 is offline Member
    Join Date
    Sep 2010
    Posts
    56
    Rep Power
    0

    Default

    Are you compiling it or running it? If you are compiling it, it will be a syntax error, not a runtime error. If you try to run this code, it won't. It is a cookie-cutter class and it does not have a "main" method. If it is a syntax error, tell us what line its on and we will help. But you will ALWAYS get a runtime error if you try to run this code.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Two things to highlight over here.

    1. Please use code tags when you are posting code segments here in the forum next time. Unformated codes are hard to read. If you don't know how to do it, check in my forum signature.

    2. Without providing more details how can we answer to your questions. We don't know what the error message is. So please provide more details next time.

    Did you run this code? I don't think so, because without a main how did you do that? (it's possible but we don't know weather you did it in another way without providing more details) So may be you end up with a compiletime error.

    Could you please post the complete error message over here to see. So we can comment on it to fix your issues.

  5. #5
    JAVA03 is offline Member
    Join Date
    Nov 2010
    Posts
    15
    Rep Power
    0

    Default

    yeah i got the mistake


    thank you all.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Posting Permissions

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