diff --git a/src/Toll/Booth.class b/src/Toll/Booth.class new file mode 100644 index 0000000..1758474 Binary files /dev/null and b/src/Toll/Booth.class differ diff --git a/src/Toll/Booth.java b/src/Toll/Booth.java new file mode 100644 index 0000000..de27838 --- /dev/null +++ b/src/Toll/Booth.java @@ -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; +} diff --git a/src/Toll/Test.class b/src/Toll/Test.class new file mode 100644 index 0000000..0bbe694 Binary files /dev/null and b/src/Toll/Test.class differ diff --git a/src/Toll/Test.java b/src/Toll/Test.java new file mode 100644 index 0000000..77637a1 --- /dev/null +++ b/src/Toll/Test.java @@ -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(); + } +} diff --git a/src/Toll/Truck.class b/src/Toll/Truck.class new file mode 100644 index 0000000..711f5e0 Binary files /dev/null and b/src/Toll/Truck.class differ diff --git a/src/Toll/Truck.java b/src/Toll/Truck.java new file mode 100644 index 0000000..d5dc1c6 --- /dev/null +++ b/src/Toll/Truck.java @@ -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; +}