|
-
December 20th, 2011, 03:31 AM
#1
Not getting any result..
Hi to all , I've started to learn Java a few weeks ago
and my home work was to create a car with license plate and speed as verables.
The speed need to be change by me and can't be more then 100 || less then 0
I've started to wright the program but the answer is always zero..
can any one help me pls..
thanks Guys.
the Code is:
public class Car {
private int Num;
private int Speed;
public Car (int x){
x=Num;
Speed=0;
}
public int SpeedC (){
return Speed;
}
public void SpeedUp (int x){
if (x >= 100)
x=100;
else
x=Speed;
}
public int SpeedUp (){
return Speed+1;
}
public void SpeedDo (int x ){
if (x <= 0)
x=0;
else
x=Speed;
}
public int SpeedDo(){
return Speed-1;
}
public void show(){
System.out.print(Num);
System.out.print(Speed);
}
}
public class Program {
public static void main(String[] args) {
Car car1 = new Car(12345);
car1.show();
Car car2 = new Car(12346);
car1.SpeedUp(5);
car2.SpeedUp(1);
car1.show();
car2.SpeedUp(30);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|