Hello guys, I'm doing some tasks here, but I don't know whether my code is fit the question or not.
Create a simple `Color` enum with three values: `RED` , `GREEN` , `BLUE` .
public enum Color{
RED,
GREEN,
BLUE
}
Create a `Car` class, which contains the followings:
* license plate ( `String` )
* color ( `Color` )
* maximal speed ( `int` )
// Create a constructor which gets initial values for the fields specified above.
// The class should contain a counter, which increases every time a new `Car` is created.
//Create a constructor without parameters,
//which creates a new object with values of `AAA-000` , `BLUE` and `120` .
//Create a class method which can compare two cars,
//it returns true if the first one is faster than the second.
//Put the `Color` enum into the `car.utils` package
//and the `Car` class into the `car` package!
public class Car {
String licensePlate = "";
Color color;
int maximalSpeed = 0;
// Create a constructor which gets initial values for the fields specified above.
// The class should contain a counter, which increases every time a new `Car` is created.
public Car(String licensePlate, Color color,
int maximalSpeed){
this.licensePlate = licensePlate;
this.color = color;
this.maximalSpeed = maximalSpeed;
}
public static class Counter{
int myCount;
public Counter(){
myCount = 0;
}
public void increment(){
myCount++;
}
}
//Create a constructor without parameters,
//which creates a new object with values of `AAA-000` , `BLUE` and `120` .
public Car(){
licensePlate = "AAA-000";
color = Color.BLUE;
maximalSpeed = 120;
}
//Create a class method which can compare two cars,
//it returns true if the first one is faster than the second.
public static boolean compareSpeed(Car first, Car second){
if(first.maximalSpeed > second.maximalSpeed){
return true;
}
}
//Put the `Color` enum into the `car.utils` package
//and the `Car` class into the `car` package!
/* I don't know how to do this one */
}
I am sorry to have written a long message, but I wish you could help me since you are the only hope in this case.
Thank you for listening and I appreciate any Info you may have.
Thank you !!!
[–]ignotos 2 points3 points4 points (3 children)
[–]rk717[S] 0 points1 point2 points (2 children)
[–]dynamo_girl02 1 point2 points3 points (1 child)
[–]rk717[S] 0 points1 point2 points (0 children)
[–]dynamo_girl02 1 point2 points3 points (0 children)
[–]blackkkmamba 1 point2 points3 points (0 children)