M
M
Miliodas202020-10-03 11:12:31
Java
Miliodas20, 2020-10-03 11:12:31

How to display the products and the quantity of each of them in the order? For example: milk was bought 3 times, cheese 1 time. How to do this?

public class Product  {
    private String name;
    private int quantity;
}

public class Order  {
    private int id;
    private Product[] products;
    private Customer customer;
}

public class Customer  {
    private String name;
    private int id;
}

public class Main {
    public static void main(String[] args)  {

}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2020-10-03
Hasanly @azerphoenix

Hello!
To begin with, write what exactly you tried and what didn’t work for you.

public class Main {
public static void main(String[] args) {

}
}

The answer to this question is similar to the answer to your previous question. Look at the response of the previous answer. Generate getters and setters.
Next, you get an array of products, and then iterate over it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question