This commit is contained in:
Orange_Dugongo 2016-10-18 17:10:13 +02:00
parent 1a15f62771
commit b1ae4633e4
6 changed files with 92 additions and 0 deletions

BIN
src/Toll/Booth.class Normal file

Binary file not shown.

48
src/Toll/Booth.java Normal file
View File

@ -0,0 +1,48 @@
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;
}

BIN
src/Toll/Test.class Normal file

Binary file not shown.

26
src/Toll/Test.java Normal file
View File

@ -0,0 +1,26 @@
public class Test{
public static void main(String [] args){
Truck tr1 = new Truck(3, 10);
Truck tr2 = new Truck(4, 14);
Truck tr3 = new Truck(3, 7);
Truck tr4 = new Truck(5, 30);
Booth bt1 = new Booth();
Booth bt2 = new Booth(10, 40);
bt1.display(tr1);
bt1.display(tr2);
bt1.receiptCollection();
bt1.display(tr3);
bt1.display(tr4);
bt1.totalReceiptCollection();
bt2.display(tr1);
bt2.display(tr2);
bt2.display(tr3);
bt2.display(tr4);
bt2.totalReceiptCollection();
bt2.receiptCollection();
}
}

BIN
src/Toll/Truck.class Normal file

Binary file not shown.

18
src/Toll/Truck.java Normal file
View File

@ -0,0 +1,18 @@
public class Truck{
public Truck(int axles, int weight){
this.axles=axles;
this.weight=weight;
}
public int getAxles(){
return axles;
}
public int getWeight(){
return weight;
}
private int axles;
private int weight;
}