OOP Lab02 ProblemModelingEncapsulation
OOP Lab02 ProblemModelingEncapsulation
OOP Lab02 ProblemModelingEncapsulation
Lecturer:
Teaching Assistant:
0. Assignment Submission
For this lab class, you will have to turn in your work twice, specifically:
§ Right after the class: for this deadline, you should include any work you have done within the lab
class.
§ 10PM two days after the class: for this deadline, you should include the final use case diagram, the
final class diagram, the source code of all sections of this lab, and the reading assignment in a
directory namely “Lab02”. Note that for the use case diagram, submit both source file (.astah) and
its exported image (.png) in the folder namely “Requirement”; for the class diagram, also submit
both source file (.astah) and its exported image file (.png) in the folder namely “Design”; for the
reading assignment, submit an image file of the reading assignment in the folder namely
“ReadingAssignment”, put all into a directory namely “Lab02” and push it to your master branch
of the valid repository.
Note that all sample codes or diagrams in the lab are only the examples/suggestions. You may need to
change them to satisfy the requirement. Each student is expected to turn in his or her own work and not give
or receive unpermitted aid. Otherwise, we would apply extreme methods for measurement to prevent
cheating. Please write down answers for all questions into a text file named “answers.txt” and submit it
within your repository.
Astah is a design tool which supports UML. To get Astah UML, go to http://astah.net/student-license-
request, fill the form, and send the request. Then follow the 3 steps in the redirected page
http://astah.net/student/thank-you. See use case diagram with Astah at http://astah.net/manual/422-usecase-
diagram.
Try to draw some several UML diagrams in the Astah UML, such as class diagram, activity diagram,
sequence diagram.
Page 1 of 12
2. Problem Statement of AIMS Project
Given the below problem statement of AIMS Project. Please read carefully the statement to ensure that you
understand clearly the software that you will design and implement from this lab. If you have any problems,
please do not hesitate to ask the professor or TA.
There might be a future that Tiki and Sendo be in talks over a potential merger to contend other e-
commerce platforms and especially those who have foreign backers. The merger of these two firms would
create a Ti-do company, where “Ti” is from Tiki, and “do” is from Sendo, which means a billion-dollar
company in Vietnamese. That firm, Ti-do company, would like you to help them create a brand-new system
for AIMS project (AIMS stands for An Internet Media Store). Currently, there is only one type of media:
Digital Video Disc (DVD).
Customers can browse the list of DVDs available in the store, the display order is based on their added
date, from latest to oldest. When a customer wants to search for DVDs to add to cart, he or she can choose
one of three searching options. The software will display a list of all matches (latest DVDs first) with all
their information. He or she can also choose to play a specific DVD. The software will play a DVD (a demo
part). If a DVD has the length 0 or less, the system must notify the customer that the DVD cannot be played.
o When a customer searches for DVDs by title, he or she provides a string of keywords. If any
DVD has the title containing any word in the string of keywords, it is counted as a match. Note
that the comparison of words here is case-insensitive.
o When a customer searches for DVDs by category, he or she provides the category name. If any
DVD has the matching category (case-insensitive), it is counted as a match.
o When a customer searches for DVDs by price, he or she provides either the minimum and
maximum cost, or just the maximum cost.
Customers can view the detail information of a DVD from the list of DVDs. He/she can add a DVD to
a cart from a list of DVDs or the detail screen.
When a customer wants to see the current cart, the system displays all the information of the DVDs,
along with the total cost. Customers may listen to a DVD (a demo part) in the cart before confirming to
place an order. Customers can sort all DVDs in the cart by title or by cost:
o Sort by title: the system displays all the DVDs in the alphabet sequence by title. In case they
have the same title, the DVDs having the higher cost will be displayed first.
o Sort by cost: the system the system displays all the DVDs in decreasing cost order. In case they
have the same cost, the DVDs will be ordered by increasing title.
Customers can update the quantity of a DVD in a cart or remove a DVD from a cart. To increase
consumer demand for the product and grow sales, customers are allowed to have an item for free which is
randomly picked out in the cart by the system. Customers can filter DVDs in the cart by providing either its
ID or title. If the item is found, display information of the found item in the cart. Or else, notify the customer
the item is not found in the current cart.
The customer can request to place order when they are seeing the current cart. For simplification, he/she
does not need to log in to place an order. The application will prompt the customer to enter the delivery
information and delivery instructions. The software will then calculate the delivery fee based on the total
mass of the order & the delivery location. Then, it will display to the customer the invoice including the
DVD list, total cost before VAT, total cost after VAT, and the delivery fee. The customer can then proceed
to pay for the order. Currently, only one payment method – i.e. credit card – is allowed by connecting to a
card association system for checking the validation of the card or performing the pay transaction. After the
transaction, the AIMS software will display all the detailed information such as transaction ID, card owner,
transaction amount, transaction message, balance, transaction date to the customer. The order will be in
pending state and the information of the order & the transaction will be sent to the customer’s email.
Page 2 of 12
The store manager needs to log in to the system to navigate to the management mode. He/she can see
the list of pending orders, then can pick any order to see its detail to approve or reject the order. The store
manager can add new DVDs to the store. He or she must provide all information of the new DVD, including
its ID, title, category, director, length, and the cost. Additionally, the manager can also remove DVDs from
the store.
A use case diagram is one of the UML diagrams to captures dynamic behaviors, i.e., the pattern of state
change over time (https://www.cs.uct.ac.za/mit_notes/software/htmls/ch05s08.html). The use case diagram
illustrates the relations among use cases. A use-case model describes a software’s functional requirements
in terms of use cases. The use-case diagram is a model of the software’s intended functions and its
environment and serves as a contract between the customer and the developers. Because it is a very powerful
planning instrument, the use-case diagram is generally used in all phases of the development cycle. For
better understanding, see https://www.uml-diagrams.org/use-case-diagrams.html.
To draw the use case diagram, you must identify the actors and use cases. A sample use case diagram is
illustrated in Figure 1 with one use case: place an order. You have to identify more use cases to update the
use case diagram for the final submission.
Figure 2. Sample class diagram for use cases related to cart management.
Page 4 of 12
Figure 3. Create Aims class by Eclipse
+ You may need to check the option "public static void main(String[] args)"
This will automatically generate the main function in the class Aims.java as the following result.
+ Because you did not choose any package for the Aims class, Eclipse then displays the icon
package and mentions (default package) for your class.
Page 5 of 12
+ You can create a package and move the class to this package if you want. In the folder scr, a sub-
folder will be created (with the name of the package) to store the class. Do it yourself and open the
src folder to see the result.
Page 6 of 12
Figure 7. Generate getters & setters by Eclipse
Page 7 of 12
Figure 9. Generated accessors
In this part, you will create yourself constructor method for DigitalVideoDisc for different purposes:
- Create a DVD object by title
- Create a DVD object by category, title and cost
- Create a DVD object by director, category, title and cost
- Create a DVD object by all attributes: title, category, director, length and cost
Page 8 of 12
Each purpose will be corresponding to a constructor method. By doing that, you have practiced with
overloading method.
Question:
- If you create a constructor method to build a DVD by title then create a constructor method to build
a DVD by category. Does JAVA allow you to do this?
Eclipse also allows you to automatically generate constructor methods by field. Just do the same as
generating getters and setters. Right click anywhere in the source file, Choose Source, Choose
Generate constructors by fields (Figure 10) then select the fields (Figure 11) to generate constructor
methods.
Page 9 of 12
Figure 11. Setup for generating constructor using fields
This is how you create the first constructor method. Similarly, you will create by yourself the others.
Page 10 of 12
9. Create the Cart class to work with DigitalVideoDisc
The Cart class will contain a list of DigitalVideoDisc objects and have methods capable of
modifying the list.
Page 11 of 12
Figure 14. Sample code of the Aims class
12. References
James Rumbaugh, Ivar Jacobson, and Grady Booch (2004). Unified Modeling Language Reference Manual,
The (2nd Edition). Pearson Higher Education
Page 12 of 12