diff --git a/labs/lab4/BandBooster.class b/labs/lab4/BandBooster.class new file mode 100644 index 0000000..2d08f31 Binary files /dev/null and b/labs/lab4/BandBooster.class differ diff --git a/labs/lab4/BandBooster.java b/labs/lab4/BandBooster.java new file mode 100644 index 0000000..06038c2 --- /dev/null +++ b/labs/lab4/BandBooster.java @@ -0,0 +1,21 @@ +public class BandBooster { + private String name; + private int boxesSold; + + public BandBooster (String name) { + this.name = name; + this.boxesSold = 0; + } + + public String getName() { + return name; + } + + public void updateSales (int addBox) { + boxesSold = boxesSold + addBox; + } + + public String toString() { + return name + " sold: " + boxesSold + " boxes!"; + } +} \ No newline at end of file diff --git a/labs/lab4/BandSale.java b/labs/lab4/BandSale.java new file mode 100644 index 0000000..3b9cd16 --- /dev/null +++ b/labs/lab4/BandSale.java @@ -0,0 +1,27 @@ +import java.util.*; + +public class BandSale { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + + System.out.println("Enter band name 1 !"); + String band1N = scan.next(); + BandBooster band1, band2; + band1 = new BandBooster(band1N); + + System.out.println("Enter band name 2 !"); + String band2N = scan.next(); + band2 = new BandBooster(band2N); + + System.out.println("Enter "+band1.getName()+" box number!"); + int box1 = scan.nextInt(); + band1.updateSales(box1); + + System.out.println("Enter "+band2.getName()+" box number!"); + int box2 = scan.nextInt(); + band2.updateSales(box2); + + System.out.println(band1.toString()); + System.out.println(band2.toString()); + } +} \ No newline at end of file