feat: create classes

This commit is contained in:
Yadunand Prem 2022-08-26 11:22:45 +08:00
parent 08f94aa5d3
commit fda7834239
4 changed files with 53 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
Lab1.pdf
Lab1.pdf
*.class

13
Customer.java Normal file
View File

@ -0,0 +1,13 @@
public class Customer {
final private int id;
public Customer(int id) {
this.id = id;
}
@Override
public String toString() {
return "Customer " + id;
}
}

15
Shop.java Normal file
View File

@ -0,0 +1,15 @@
public class Shop {
private ShopCounter[] counters;
public Shop(ShopCounter[] counters) {
this.counters = counters;
}
public ShopCounter getAvailableCounter() {
for (int i = 0; i < this.counters.length; i++) {
if (this.counters[i].isAvailable())
return counters[i];
}
return null;
}
}

23
ShopCounter.java Normal file
View File

@ -0,0 +1,23 @@
public class ShopCounter {
final private int id;
private boolean available;
public boolean isAvailable() {
return available;
}
public void setAvailable(boolean available) {
this.available = available;
}
public ShopCounter(int id) {
this.id = id;
this.available = true;
}
@Override
public String toString() {
return "Counter " + id;
}
}