Assignment 1
Assignment 1
Assignment
Learning outcome:
Upon successful completion of this assignment, you will have demonstrated the abilities
to:
Uses streams to read and write data from/to different types of sources/targets
Describe to your instructor what you have learned in completing this workshop.
Scenario
The car showroom, named Minh Trang BMW, has a list of BMW cars. BMW brands are stored in a text
file, named brands.txt, and cars are stored in a text file, named cars.txt as following:
1
Problem requirements
The manager of the showroom needs a Java console application in which operations must be supported:
1- List all brands
2- Add a new brand
3- Search a brand based on its ID
4- Update a brand
5- Save brands to the file, named brands.txt
6- List all cars in ascending order of brand names
7- List cars based on a part of an input brand name
8- Add a car
9- Remove a car based on its ID
10- Update a car based on its ID
11- Save cars to file, named cars.txt
Constraints
1- Constraints on brands:
a. Brand ID can not be duplicated.
b. The brand name can not be blank.
c. The sound manufacturer can not be blank.
d. The price must be a positive real number.
2- Constraints on cars:
a. Car ID can not be duplicated.
b. Brand ID must have existed and it must be inputted using a menu.
c. Color can not be blank.
d. Frame ID can not be blank and must be in the “F00000” format and can not be
duplicated.
e. Engine ID can not be blank and must be in the “E00000” format and can not be
duplicated.
Analysis
From the problem description, main concepts and their details are identified:
Concept Detail
Brand Brand ID, brand name, sound brand, price
List of brands
Car Car ID, brand ID, color, frame ID, engine ID
List of cars
Menu A list of objects
Program A menu, a list of brands, a list of cars
2
Design
1- Class Design outline
Menu
<used>
<used> <used>
CarManager
Menu
Public int int int_getChoice(ArrayList<E>): Get user choice as an integer.
int_getChoice(ArrayList<E>) E ref_getChoice(ArrayList<E>): Get the object chosen by user.
Public E
ref_getChoice(ArrayList<E>)
3
Java.lang.Comparable
CarManager
4
4- Test cases
5
using a menu. Choose B5-18
- Color can not be blank.( black/ yellow)
- Frame ID can not be blank and must be in the “F00000”
format and can not be duplicated (K0123/ F12345/
F12352).
- Engine ID can not be blank and must be in the
“E00000” format and can not be duplicated (M0123/
M12345/ E12352)