I am new to Java (taking it to get warmed up for C and C+++ as I am very rusty.)
I am writing a class that is suppose run the file DLTest.java(written by the instructor) that is suppose to keep track of two licenses with name and tickets. DrivingLicense, ().addTicket, ().name,().numTickets, and ().isSuspended are all objects in this class.
My program is suppose to "name" driver one and two(Alice/Bob), tying their existing tickets(2/0) so that the DLTest can make this output:
Alice does NOT have a suspended license
Bob does NOT have a suspended license
Bob and Alice are both caught speeding!
(this program doesn't loop and at this point it is suppose to add a ticket to each driver to make this output)
(my problem is getting the numTicket to increase by one)
Alice has a suspended license!
Bob does NOT have a suspended license
public class DrivingLicense {
String name;
int numTickets, a;
boolean isSuspended, addTicket;
public DrivingLicense() {
name = null;
numTickets = 0;
isSuspended = addTicket;
}
public DrivingLicense (String name, int numTickets){
this.name = name;
this.numTickets = numTickets;
}
public boolean isSuspended() {
if (numTickets <= 2) {
return true;}
return false;}
public boolean addTicket() {
numTickets = a;
if (a+1 >= 2) {
return false;}
return true;
}
}
I don't understand why it is forcing me to do have to make a return statement twice, I can't seem to get d1.license to become d1.isSuspended after the "ticket".