feat: create classes
This commit is contained in:
parent
08f94aa5d3
commit
fda7834239
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
|
||||
Lab1.pdf
|
||||
Lab1.pdf
|
||||
*.class
|
||||
|
13
Customer.java
Normal file
13
Customer.java
Normal 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
15
Shop.java
Normal 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
23
ShopCounter.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user