FIT9131数据仓库

FIT9131 Semester 1 2021 Assignment 2
25 April 2021 1
Used Car Warehouse Database System
Due Date: 10:00pm on Friday in Week 12 (28 May 2021)
Introduction
This assignment is worth 25% of the marks for your final assessment in this unit. Heavy penalties will
apply for late submission. This is an individual assignment and must be entirely your own work. You must
attribute the source of any part of your code which you have not written yourself. Please read the section on
plagiarism in this document. Your program will be checked with a code similarity detector. Please note the
section on plagiarism in this document.
The assignment must be done using the BlueJ environment. All user input to the system, and system
output to the user, must be done at the BlueJ terminal window. No other graphical interfaces are to be
used (nor assessed) in your program.
The Java source code for this assignment must be implemented according to the FIT9131 Java Coding
Standards.
Any points needing clarification should be discussed with your tutor in your lab classes. You should not
make any assumptions about the program without consulting your tutor.
Learning outcomes
1) Design, construct, test and document small computer programs using Java.
2) Interpret and demonstrate software engineering principles of maintainability, readability, and
modularisation.
3) Explain and apply the concepts of the "object-oriented" style of programming.
Specification
For this assignment you are required to write a program that implements a simple Used Car Warehouse
Database System. This section specifies the required functionality of the program. Only a simple text
interface (using the BlueJ Terminal Window) is required for this program; however, more marks will be
gained for a program that is easy to follow with clear information/error messages to the user.
Even though this program is functionally very different from the program you wrote in Assignment 1, you
should be able to re-use much of your previous code here - if you have designed the classes/logic in your
previous program properly. This is one of the major benefits of an object-oriented program - the ability to
re-use classes.
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 2
The aim of the Used Car Warehouse Database System is for a virtual warehouse to keep a database of the
used cars in the warehouse, and to perform operations such as searching for cars, adding/deleting/editing
cars, displaying the details of cars, etc.
The Used Car Warehouse Database System should provide the following features:
• maintains a list (using a Java Collection class) of Car objects
o each Car object represents a single “car”
o cars can be searched/added/deleted/edited from the list
• maintains a list (using a Java Collection class) of CarMaker objects
o each CarMaker object represents a car "manufacturer" (maker)
• produces a report of cars based on some criteria
• loads a list of cars from a text file; saves the list of current cars to a text file
• loads a list of car makers from a text file
You are to demonstrate the following programming techniques in your program:
• reading/writing data from/to text files
• using appropriate Java Collection classes to store data (including embedded objects)
• manipulating the data in the collection(s)
• performing simple searches, filtered by some given criteria
• using program constructs such as repetitions & selections
• using appropriate classes to represent objects in the program
There will be a description of the Car and CarMaker classes (and the collection classes which store them)
later in this document.
You are also required to produce a partial Test Strategy for your program.
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 3
Program Logic
When the Used Car Warehouse Database System starts, it should automatically load 2 text files:
• "usedcars.txt" which contains details of all used cars currently kept by the warehouse
• "carmakers.txt" which contains details of all available car makers known to the warehouse
The actual formats of these text files are described later in this document. The data loaded should be stored
in some appropriate data structures (the "databases" – stored in memory). No other reading from (or writing
to) file is required while the program is in operation, until the user chooses to exit, at which point the
program saves all the in-memory cars' data back to the same text file (usedcars.txt) – the
carmakers data does not need to be saved as it is not modified by this program.
In other words, all the file I/O operations are performed automatically by the program, once at the start and
once at the end, and require no interactions with the user.
When the program is running, it should repeatedly display a main menu with these options:
(1) Search Cars
(2) Add Car
(3) Delete Car
(4) Edit Car
(5) Exit System
Option (1) of the main menu allows the user to search for cars in the database. The user should be asked
what criteria(s) he/she wants to use to search for cars. The following sub-menu and options should be
displayed when this option is selected:
Car Searching Options:
(1) By Registration Number
(2) By Car Make and Car Model
(3) By Car Age
(4) By Price (range)
(5) Back to Main Menu
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 4
Sub-menu operations:
• Option (1): the program should ask the user to input a registration number. A valid registration
number should only contain a maximum 6-character combination of English alphabet or
digit (that is, “A”-“Z”, “a”-“z” or “0-9”). If the input contains any invalid character (e.g. empty
space, “#”, “&”, “\” etc.) or more than 6 characters, an error message should be displayed and
the user is prompted for another valid input. If it is a valid input, the database will be searched
for the car matching the specified car registration number. If found, all information for this car
should be displayed; otherwise, some sensible error message (e.g. “No such car with this
Registration Number”) should be displayed.
• Option (2): the program should ask the user to input a Car Make and Model (eg. "Toyota" and
"Corolla"). Important requirement - when entering the make and model, the user must be able
to select from a list of available values (values are read from the "carmakers" input file when
the program starts) – instead of manually typing in the values. When entering the model, the user
can also input a special value of “ANY”, to display all car models from this Car Maker from the
database. As in sub-menu Option (1), the program should display the appropriate search results.
• Option (3): the program should ask the user to input a non-negative integer (e.g. 0, 1, 5, 12 etc.)
to indicate the maximum age of cars they want to search. The entered value should again be
validated. As in sub-menu Option (1), the program should display the appropriate search results.
For example, if the user inputs 0, all cars made in 2021 (current year) should be displayed. If the
user inputs 3, all cars made in 2018, 2019, 2020, 2021 should be displayed.
• Option (4): the program should ask the user to input a minimum price and a maximum price of
cars they want to search. Both inputs should be positive integers and the maximum price should
be greater than the minimum price. As in sub-menu Option (1), the program should display the
appropriate search results. For example, if the user inputs minimum price = 1000 and maximum
price = 3000, all cars priced from $1000 to $3000 (both inclusive) should be displayed.
• Option (5): the program should go back to the main menu.
Option (2) of the main menu allows the user to add a new car to the database (appropriate input validity
checking should be applied). No duplicate cars are allowed. When entering the make and model, the user
must again be able to select from a list of available values (initialized from the "carmakers" input file).
Option (3) of the main menu allows the user to delete an existing car from the database. The user should be
asked to search the car by Registration Number (appropriate input validity checking should be applied).
Option (4) of the main menu allows the user to edit an existing car from the database. The user should be
asked to search the car by Registration Number (appropriate input validity checking should be applied).
The only 2 fields which can be edited are the Colour and Price.
Option (5) of the main menu exits the program. All the cars currently stored in the in-memory database are
automatically saved back to "usedcars.txt".
Additional Notes:
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 5
Both the main menu and the sub-menu must be displayed repeatedly after each menu operation, until the
user chooses the appropriate exit option. All invalid inputs (including non-numeric or other speical
characters) should be rejected, and an error message printed.
If the user chooses Options (2) in the main menu, the Car Make and Model MUST be selected from a list
which came from the data read (at the start of the program) from carmakers.txt.
Your program must deal in a sensible way with any invalid values entered by the user.
For all the user interactions, the inputs/outputs can be formatted in many different ways. Discuss with your
tutor regarding how you should implement these in your program.
Your user interface need not be exactly as shown in the examples shown above. However, you should
discuss with your tutor about what to include in your user interface. Keep it simple.
Important: see the Program Design section below for a description of what classes you need to
implement in your program. Failure to implement those required classes will cause loss of marks.
There will be some hints in the forum on Moodle later regarding how you should develop the program for
this assignment. Make sure you check them out when they are available.
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 6
Important Requirements
You must satisfy the following requirements when implementing your program:
• a Car object remembers the following data:
o registration number: String
▪ must not be blank, must be numeric/alphabetic (e.g. 8RT2WT)
▪ maximum 6 characters
▪ must be unique (no duplicates)
o year made: int
▪ between 1950-2021 (inclusive)
o colour: Strings
▪ a car can have up to 3 colours (e.g. White + Blue)
o car make: String
▪ any valid car maker (e.g. Toyota)
o car model: String
▪ any valid model (e.g. Corolla)
o price: int
▪ between 500-30000 (inclusive)
• a CarMaker object remembers the following data:
o name: String
▪ a non-empty String, must not contain commas
o available models: Strings
▪ a list of car models available from the car maker, must not contain commas
• you must use appropriate Java data structures to store the Car and CarMaker objects in your
program – see the Program Design section for more details.
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 7
• you may assume that the input data files are always in the correct formats (see below) - ie. there is
no need to validate the actual data when reading them in.
• all operations must be applied to the in-memory data structures - there must not be constant
reading/writing to/from the data file, except once at the start (when the program loads all data from
the files) and once at the end (when the program saves all data back to the file, when it exits)
• the program must not crash when accepting user inputs, regardless of what the user enters.
• all Car Registration Numbers are unique - if a car with the given Car Registration Number is
already in the database, it cannot be added again, and an error message should be displayed.
• there is no limit to how many cars can be stored.
• there is no limit to how many car makers can be stored.
o there is no limit to how many models are available from a particular car maker.
• when performing searches, all search strings are not case-sensitive (e.g. there is no difference
between “178XYZ”, “178xyz” or “178XyZ” for car registration number).
Input File Formats
The first input data file (usedcars.txt) has the following format for each line (note that there is no
empty space in between a word and a comma). If a car has less than 3 colours, the corresponding fields are
empty.
CarRego,YearMade,Colour1,Colour2,Colour3,CarMake,CarModel,Price
• CarRego is a String.
• YearMade is a positive integer.
• Colour1/Colour2/Colour3 are Strings.
• CarMake is a String with no empty space inside.
• CarModel is a String.
• Price is a positive integer.
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 8
Here is an example of a usedcars.txt file:
1YX98J,2014,Black,White,,Toyota,RAV4,25000
ABC132,2007,Yellow,,,Toyota,Corolla,5900
MARY21,2017,Dark Grey,Blue,Red,BMW,X5,55132
90210,2012,Blue,Light Green,,Honda,Civic,2000
The second input data file (carmakers.txt) has the following format for each line (note that there is no
empty space in between a word and a comma). A car maker can have as many models as there are data in
the file.
Make,Model1,Model2,Model3,Model4,Model5,…
• Make is a String representing a Car Maker.
• Model1/Model2/… are Strings representing the models available for that Car Maker.
Here is an example of a carmakers.txt file:
Toyota,Prius,Corolla,Camry,Celica
Holden,Commodore,Barina,Apollo,Astra
Hyundai,Sonata,Elantra,Tucson
Kia,Sportage,Stinger,Carnival,Sorento
MyOwnBrand,Thor,Ironman,Hulk,Superman,Thanos,Shrek
You may assume:
• the strings which represent the various fields (colours/make/etc) do not contains commas.
• this program does not provide the functionality to edit the carmakers list (i.e. use a text editor to
edit "carmakers.txt" if you wish to modify the list).
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 9
Program Design
Your program must demonstrate your understanding of the object-oriented concepts and general
programming constructs presented in FIT9131. Consider carefully your choice of classes, how they interact
and the fields and methods of each class.
You must use appropriate data structures to store the various objects (list of cars, list of car makers, list of
models, etc) in the program. If you do not understand what this means, ask your tutor now.
You must be able to justify the choice of the data structures during your interview. You must document any
additional assumptions you made.
Appropriate validations of values for fields and local variables should also be implemented. You should not
allow an object of a class to be initialized/set to an invalid state (ie. put some simple validations in your
mutator methods).
Discuss with your tutor what classes are appropriate, and how they interact with each other. The main
requirements are:
(1) the cars must be implemented as objects, and they must be stored in some appropriate Java
collections (e.g. an ArrayList of Car)
(2) the car makers must also be implemented as objects, and they must be stored in some appropriate
Java collections (e.g. an ArrayList of CarMaker)
Your program must deal with invalid values entered by the user in a sensible manner. For instance, if a user
enters "abc" when a number is expected, your program should not crash.
Exception handling should be used where appropriate.
All on-screen input/output should be formatted in a user-friendly manner. Sensible error messages should be
displayed whenever appropriate (e.g. entering a duplicate car to add, entering a price outside the allowable
valid range, etc).
Note: The description of the program’s logic/design is purposely left vague, to give you some room to
exercise your own design and creativity. Discuss with your tutor about what/how to implement.
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 10
Test Strategy
For this assignment, you are required to produce a partial Test Strategy for the program.
There is no need to produce Test Strategy for any other classes you have used in your program.
You must provide a Test Plan, plus detailed sets of Test Data, Expected Results and Actual Results for the
Car class.
Your Test Strategy will be only for one class - the Car class.
Your program must consist of at least these classes:
• CarWarehouse – main class, which contains the program's main logic
• Car – represents a single car
• CarMaker – represents a single car maker
• CarDatabase – represents a list of cars
• CarMakerDatabase – represents a list of car makers
any other appropriate classes (e.g. a Menu class) are to be discussed with your own tutor
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 11
Assessment
Assessment for this assignment will be done via an interview with your tutor. The marks will be allocated as
follows:
• 10% - Test Strategy for the Car class.
• 35% - Java Code & Object-Oriented design quality. This will be assessed on appropriate
implementation of classes, fields, constructors, methods, and validations of the objects' states.
• 55% - Program Functionality in accordance with the requirements.
You must submit your work by the submission deadline on the due date (a late penalty of 10% per day,
inclusive of weekends, of the possible marks will apply - up to a maximum of 100%). There will be no
extensions - so start working on it early.
Marks will be deducted for incomplete/untidy submissions, and non-conformances to the FIT9131 Java
Coding Standards.
All submitted source code must compile. Any submission that does not compile, as submitted, will receive a
grade of ‘N’.
Interview
You will be asked to demonstrate your program at an "interview" following the submission date. At the
interview you can also expect to be asked to explain your code/design, modify your code, and discuss your
design decisions and alternatives. Marks will not be awarded for any section of code or functionality that a
student cannot explain satisfactorily (the marker may also delete excessive in-code comments before you are
asked to explain that code).
In other words, you will be assessed on your understanding of the code, and not on the actual code itself.
The interviews will be arranged during week 12 and will take place online via Zoom or other video facility
after that week. You must have audio and video available and operating during the interview. It is your
responsibility to make yourself available for an interview time and ensure that you have the audio and video
capabilities. Any student who does not attend an interview will receive a mark of 0 for the assignment.
FIT9131 Semester 1 2021 Assignment 2
25 April 2021 12
Submission Requirements
The assignment must be uploaded to Moodle on or before the due date. The link to upload the assignment
will be made available in the Assignments section of the unit’s Moodle site before the submission deadline.
The submission requirements are as follows:
A ZIP file uploaded to Moodle containing the following components:
• the BlueJ project you created to implement your assignment. The ZIP file should be named with your
Student ID Number. For example, if your id is 12345678, then the file should be named
12345678_A2.zip. Do not name your file any other way.
• it is your responsibility to check that your ZIP file contains all the correct files, and is not corrupted,
before you submit it. If you tutor cannot open your zip file, or if it does not contain the correct files,
you will not be assessed.
• an MS Word document containing your Test Strategy for the Car class. (Note: The JUnit facility in BlueJ
is NOT to be used for this assignment)
• there is no need to submit a physical Assignment Cover Sheet – you will be asked to accept an online
submission statement when you submit the assignment.
Marks will be deducted for failure to comply with any of these requirements.
Warning: there will be no extensions to the due date. Any late submission will incur the 10% per day
penalty. It is strongly suggested that you submit the assignment well before the deadline, in case there
are some unexpected complications on the day (e.g. interruptions to your home internet connection).
Plagiarism
Cheating and plagiarism are viewed as serious offences. In cases where cheating has been confirmed,
students have been severely penalised, from losing all marks for an assignment, to facing disciplinary action
at the Faculty level. Monash has several policies in relation to these offences and it is your responsibility to
acquaint yourself with these.
Monash Plagiarism Policy:

你可能感兴趣的:(数据库)