Commit e7687a83 authored by 9533054's avatar 9533054

testing

parent f43f583d
Pipeline #63 failed with stages
import java.util.ArrayList;
/**
* Class for modeling licensePlate of cars
* @author Ghazal Sadeghian
* @version 2018.10.19
*/
public class LicensePlate {
private String number;
private boolean validity;
private String ownerFistName;
private String ownerFamilyName;
private ArrayList<String> trafficTickets;
/**
* Create a new licensePlate with given informations
* @param number number of licensePlate
* @param ownerFistName name of the owner of the car
* @param ownerFamilyName familyName of the owner of the car
*/
public LicensePlate(String number, String ownerFistName, String ownerFamilyName) {
this.number = number;
this.ownerFistName = ownerFistName;
this.ownerFamilyName = ownerFamilyName;
validity = true;
trafficTickets = new ArrayList<String>();
}
/**
* Print traffic offences of the licensePlate
*/
public void printTrafficTickets() {
System.out.println("Traffic offences of this licenseplate :");
for (String ticket : trafficTickets) {
System.out.println((trafficTickets.indexOf(ticket))+1 + ":" + ticket);
}
}
/**
* Adding new ticket to the list of traffic offences and checking validity of the licensePlate
* @param newTicket title of new ticket to be added
*/
public void addTicket(String newTicket) {
trafficTickets.add(newTicket);
if ((trafficTickets.size()) >= 5)
validity = false;
}
/**
* Removing the selected ticket from the list and checking validity of the licensePlate
* @param ticket title of selected ticket to be removed
*/
public void removeTicket(String ticket) {
trafficTickets.remove(ticket);
if ((trafficTickets.size()) <= 5)
validity = true;
}
/**
* printing whether the license is valid or not.
*/
public void printValidity() {
if (this.validity)
System.out.println("this licensePlate is valid");
else
System.out.println("this licensePlate is not valid");
}
}
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment