programmazione-java/src/Toll/Booth.java
Orange_Dugongo b1ae4633e4 toll
2016-10-18 17:10:13 +02:00

49 lines
1.1 KiB
Java

public class Booth{
public Booth(){
this.dueAxles=5;
this.dueTon=20;
count=0;
cash=0;
}
public Booth(int dueAxles, int dueTon){
this.dueAxles=dueAxles;
this.dueTon=dueTon;
count=0;
cash=0;
}
private int calcToll(Truck tr){
return tr.getWeight()*dueTon + tr.getAxles()*dueAxles;
}
public void display(Truck tr){
int money;
System.out.println("Truck arrival - axles: "+tr.getAxles()+" total weight: "+tr.getWeight());
money=calcToll(tr);
System.out.println("Toll due: "+money);
cash+=money;
count++;
}
public void receiptCollection(){
System.out.println("*******");
System.out.println("Receipts: "+cash);
System.out.println("Truck: "+count);
System.out.println("*******");
}
public void totalReceiptCollection(){
System.out.print("*******Total");
receiptCollection();
count=0;
cash=0;
}
private int dueAxles;
private int dueTon;
private int count;
private int cash;
}