Separate listings of an object for each object of the type of another class

Asked

Viewed 261 times

-1

Good night. My question is in relation to the algorithm of my project, I am trying to make an application where each Customer can place several orders but each order belongs to a different Customer. I still remember that "one for many" logic and the aggregation where each client has a request as well. Only I do not know how to do this in the graphical interface of the program to separate each order by a client, how would I make the logic more or less in the application? Thank you.

  • 1

    I believe that declaring Customer with the attribute of List<Orders> and each Order has an attribute idClient to identify the customer is sufficient.

  • I will try to do as you said Daniela, maybe the problem is that I took this test in main() it ended up working out but when I went to divide the customers in a form I ended up not getting

1 answer

0


Graphical Interface

In the Graphical Interface you can make a Client table, with columns like "Customer Name", "Order Quantity", etc. That is, each Row with a different Customer.

By clicking on a Line from this Client table you open another Screen with another Table; this second Screen will have the information of the Client and, inclusive, will have a Order Table of this Customer, with Columns such as "Order Quantity", "Order Date", etc. All Orders made by this Customer will be in this Table.

When Clicking on a Line from Order Table you can open in another Screen (or open in a "Box Accordion" [floating or not] below the Row) a Table with the Items that are in this Order, where the Columns would be "Product Name", "Quantity", "Unit Value", "Total Value", etc.

See an Example I created here from the Client Data Screen: inserir a descrição da imagem aqui

Note that you will need many more things, such as payment methods, installments, etc. This is just a layou idea.

Class Design (application logic):

You can create a "Client" Class that will have a "Request" Object List, each "Request" Object will have "Itemped" Object List, and each "Itemped" Object will have:

  • A (Exactly ONE) Object "Item" (the Product) that already has its "Code" and its Name;
  • The Quantity (int with units purchased in this Order);
  • The "Unit Value", the "Total Value" (which is "quantity * valueUnited"), and the "Paid Value".

Remember to use "Money and Currency API" or at least BigDecimal to handle money, do not use double for this (see here why use Bigdecimal instead of Double to handle money).

  • This helped me to clear up the idea in separating each order list for each customer!! I was not aware before this division and was confused in listing all orders from all customers and after doing a survey of a client by id to then generate the total value but I don’t know if that would be right either.. helped to resolve my doubt!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.