class Product {
private final int id. private String description; private double price;
public Product(int IDnumber, String descr. double price){ id = IDnumber; description = descr, this.price = price; System.out.pri ntln(toString());
}
public String toStringO {
return id + " + description + ", цена: $" + price;
public void priceChange(double change) { price += change,
}
public static Generator<Product> generator = new Generator<Product>() {
private Random rand = new Random(47), public Product next О {
return new Product(rand nextlnt(lOOO), "Test",
Math round(rand nextDoubleO * 1000 0) + 0 99).
class Shelf extends ArrayList<Product> { public Shelf(int nProducts) {
Generators fill(this. Product generator. nProducts),
class Aisle extends ArrayList<Shelf> {
public AisleCint nShelves, int nProducts) { for(int i = 0; i < nShelves; i++) add(new Shelf(nProducts)),
class CheckoutStand {} class Office {}
public class Store extends ArrayList<Aisle> {
private ArrayList<CheckoutStand> checkouts =
new ArrayList<CheckoutStand>(); private Office office = new OfficeO. public Store(int nAisles, int nShelves, int nProducts) { for(int i = 0; i < nAisles; i++)
add(new Aisle(nShelves. nProducts));
}
public String toStringO {
StringBuilder result = new StringBuilderO; for(Aisle a this)
for(Shelf s : a)
for(Product p • s) {
result.append(p); result.append("\n").
}
return result.toStringO.
}