lab 4
This commit is contained in:
parent
b050db6dce
commit
a5b35aabb3
BIN
labs/lab4/BandBooster.class
Normal file
BIN
labs/lab4/BandBooster.class
Normal file
Binary file not shown.
21
labs/lab4/BandBooster.java
Normal file
21
labs/lab4/BandBooster.java
Normal 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
27
labs/lab4/BandSale.java
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user