This commit is contained in:
k0rrluna 2025-01-10 05:01:59 +03:00
parent b050db6dce
commit a5b35aabb3
3 changed files with 48 additions and 0 deletions

BIN
labs/lab4/BandBooster.class Normal file

Binary file not shown.

View File

@ -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!";
}
}

27
labs/lab4/BandSale.java Normal file
View File

@ -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());
}
}