[go: up one dir, main page]

0% found this document useful (0 votes)
66 views6 pages

Assignment 1

This document provides details for an assignment to create a Java console application to manage a list of BMW car brands and vehicles. The application must support 11 operations: listing, adding, searching, updating, and saving brands and vehicles. It also outlines the class design including classes for Menu, Brand, BrandList, Car, CarList, and CarManager. Test cases are provided to validate the required functionality and constraints for each operation.

Uploaded by

thuannvhe186834
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views6 pages

Assignment 1

This document provides details for an assignment to create a Java console application to manage a list of BMW car brands and vehicles. The application must support 11 operations: listing, adding, searching, updating, and saving brands and vehicles. It also outlines the class design including classes for Menu, Brand, BrandList, Car, CarList, and CarManager. Test cases are provided to validate the required functionality and constraints for each operation.

Uploaded by

thuannvhe186834
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PRO192: OOP in Java

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

 Identify classes, objects, members of a class, and relationships among them


needed for a specific problem

 Explain the concept and demonstrates the use of Polymorphism, Encapsulation,


Abstraction, and Inheritance in java

 Understand and implement a complete program using a collection framework

 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:

File brands.txt Description


B7-2018, BMW 730Li (2018), Harman Kardon: 3.749 Information in a line:
B7-MS, BMW 730Li M Sport, Harman Kardon: 4.319 <ID, brand name, sound brand:
B7-MS20, BMW 730Li M Sport (2020), Harman Kardon: 4.369 price>
B7-PE, BMW 730Li Pure Excellence, Harman Kardon: 4.929
B5-18, BMW 530i (2018), Alpine: 2.599
B7019, BMW 530i (2019) , Alpine: 2.729
BX4-18, BMW X4 xDrive20i (2018), Sony: 2.799
BX4-17, BMW X4 xDrive20i (2019) , Sony: 2.899
B3-GT18, BMW 320i GT (2018), Bose: 1,799
B3-S19, BMW 320i Sportline (2019), Bose: 1.899
B5-X19, BMW X5 xDrive40i XLine (2019), Bose: 4.199
B5-X20, BMW X5 xDrive40i XLine (2020), Bose: 4.239

File cars.txt Description


C01, B7-2018, red, F12345, E12345 Information of a line:
C02, B7-2018, black, F12346, E12346 <ID, brand ID, color, frame ID, engine ID>
C03, B7-MS, orange, F12347, E12347
C04, B7-MS20, white, F12348, E12348
C05, B7-PE, pink, F12349, E12349
C06, B5-18, pink, F12350, E12350
C07, B5-X20, grey, F12351, E12351

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

Brand <used> BrandList Java.util.ArrayList <Brand>

Car <used> CarList Java.util.ArrayList <Car>

<used>
<used> <used>

CarManager

2- Class Design in Details

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>)

Brand BrandList Java.uti.ArrayList


<Brand>
String brandID, public BrandList();
brandName, public boolean loadFromFile(String);
soundBrand public boolean saveToFile(String); toString():
double price public int searchID (String ID); For print a brand in a
public Brand getUserChoice(); menu.
public Brand(); public void addBrand();
public Brand(String, public void updateBrand(); Brand getUserChoice():
String, String, double); public void listBrands(); Supporting menu for user
public Getters/ setters; choosing a brand when a
public String toString(); car is added/updated.

3
Java.lang.Comparable

<implement> for sorting

Car CarList Java.uti.ArrayList


<Car>
String carID // brand list must be existed in advance
Brand brand BrandList brandList;
String color public CarList(BrandList bList);
String frameID public boolean loadFromFile(String);
String engineID public boolean saveToFile(String);
public int searchID (String ID);
public int searchFrame (String fID);
public Car()
public int searchEngine (String eID);
public Car (String, Brand,
public void addCar();
String, String, String);
public void printBasedBrandName ();
public Getters/ setters;
public boolean removeCar();
String toString();
public boolean updateCar();
public int comparedTo(Car);
public void listCars();
public String toString();
public String screenString();

CarManager

public static void main(String [] args);

3- Software Structure design


Project name: CarPrj
Package structure:

4
4- Test cases

Test Option Objective Requirements


1 1 List all brands All brands in the file must be shown correctly
[0.5 point]
2 2 Add a new brand  Brand ID can not be duplicated.
[1 point]  Brand name can not be blank.
 Sound manufacturer can not be blank.
 Price must be a positive real number.
Add:
B7-MS2, BMW 730Li M, Alpine: 4.050
3 3 Search a brand based Test 2 cases:
on it’s ID [1 point] - BrandID = B5-30  Not found
- BrandID = B5-18  Brand result is shown.
4 4 Update a brand  Brand name can not be blank.
[1 point]  Sound manufacturer can not be blank.
 Price must be a positive real number.
Update: B7-MS, BMW 730Li M Sport, Harman Kardon: 4.319
To: B7-MS, BMW 730Li MS, Sony: 4.150
5 5 Save brands to the file, This operation must be successful.
named brands.txt Open the file to check its content.
[1 point]
6 6 List all cars in All cars in the file must be shown in ascending order of
ascending order of brand names and their ID.
brand names
[1 point]
7 7 List cars based on a Input: “960”: No result
part of an input brand Input: “730”: All cars of the brand 730 must be shown.
name
[1 point]
8 8 Add a car - Car ID can not be duplicated (C05, C08)
[1 point] - Brand ID must have existed and it must be inputted

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)

Add: C08, B5-18, yellow, F12352, E12352  successful


9 9 Remove a car based C10  Not found.
on its ID C06  Remove successfully.
[1 point]
10 10 Update a car based on ID = C10  Not found.
its ID ID= C03
[1 point] Update: C03, B7-MS, orange, F12347, E12347
To: C03, B5-18, brown, F99999, E99999
- Brand ID must have existed and it must be inputted
using a menu. Choose B5-18
- Color can not be blank. ( black/ brown)
- Frame ID can not be blank and must be in the “F00000”
format and can not be duplicated (K0123/ F12345/
F99999).
- Engine ID can not be blank and must be in the
“E00000” format and can not be duplicated (M0123/
M12345/ E99999)
11 11 Save cars to file This operation must be successful.
[0.5 point] Open the file to check its content.

You might also like