I have an class called car with attributes and one of those attributes being a license number which I have to show printed and it must fulfil being only 6 chars long and having 3 characters and 3 numbers as such: ASF817
Also if somebody inputted their license plate number being wrong, how would I tell print some code to say it is wrong?
I'm not sure of what method to use at all to restrict to exactly specific values.
public class Car {
private String regNo;
private String make;
private String model;
private String driverName;
private int passengerCapacity;
private boolean available;
private String[] Booking = {"currentBookings, pastBookings"};
public Car(String regNo, String make, String model,
String driverName, int passengerCapacity) {
this.regNo = regNo;
this.make = make;
this.model = model;
this.driverName = driverName;
if(passengerCapacity < 0)
{
this.passengerCapacity = 1;
}
else if(passengerCapacity > 10)
{
this.passengerCapacity = 10;
}
else
{
this.passengerCapacity = passengerCapacity;
}
System.out.println(this.passengerCapacity);
Need to make String regNo only be 6 chars, with 3 characters first and 3 numeric values after when inputted by a user. Thank you.