CSE 174 - Assignment 4
Deadline: Monday, Dec 6th at 11:59 PM
You are to write a program that reads data from a file, and creates and works with an ArrayList
of Customer objects.
● Create a new class/file called Assignment4.
● Download theAPI Documentation for Customer Class.
● Download theCustomer.java(DO NOT CHANGE ANYTHINGINSIDE THIS FILE),list.txt, and
customers.txtfiles and put them in the same folderas your Assignment4.java file.
For this assignment you are allowed to use everything you have learned so far to generate the expected output.
There are only 2 limitations that you must follow:
- The length of methods (including the main method) should be less than 35 lines.
- Your class must have 2 public sort methods called sort1 and sort2 which are explained later.
Other than that, you can use anything that you have learned in this course.
The quality of your code will be evaluated by the assessor and points will be taken off if you don’t follow
the proper programming practices. So, avoid using things that we have never used in the course.
Part1: Run the program
When your program is run, the following menu needs to be displayed:
At this point nothing has been read from the file, so if the user chooses menu options from 2-5,
nothing should happen and the user should be prompted with a proper message as the following:
Part2: Reading from a file & creating an ArrayList of Customer objects
When the user enters 1, it asks the user to enter a filename and starts reading data from the given
file and creates an ArrayList of Customers. The following is the result:
When option 1 is done:
● The user can enter 2 to display the list.
● Choosing number 2 only displays 10 elements at a time. If the user enters character ’s’, it will
stop showing the rest of the list. If the user enters anything else, it will show the next 10 elements
of the list and so on.
● At this level if the user enters number 5, nothing should be printed because the list hasn’t been
sorted yet.
1 | The results are as follows: |
Part3: Sorting
Your class must have 2 sort methods called sort1 and sort2. These two methods both accept an
ArrayList of Customer objects and return nothing .From the sorting algorithms that you have learned so
far (bubble sort, selection sort, and insertion sort) you can pick any one you like for sort1 and sort
methods. For instance, you can use bubble sort for sort1 and insertion sort for sort2, or you can use the
same sort algorithm for both sort1 and sort2 methods.
The sort1 method should sort the list based on nicknames ,and the sort2 method should sort the list based
on the id numbers.
● When the user enters 3, the list should be sorted by nicknames.
● When the user enters 4, the list should be sorted by id numbers.
● The last sorted list can be displayed by entering5.
● If the user enters 2, the original, unsorted liststill needs to be displayed as before.
The results are as follows:
Part4: Loading another file
If the user enters 1 again to load another file, everything will be repeated from part2. Please go back
and read part2 of this assignment again.
Part5: Test your code with more sample runs
Just follow the following sample runs to test your code and make sure that your code is generating the
same results..
Part6: Submit on Canvas
If your program worked as shown above, now it’s time to submit your work on Canvas. The Code
Plugin will test the result of your code, along with sort1 and sort2 methods.
Rubric
1 | Criteria Full Credit Partial Credit No Credit |
1 | Successful |
1 | A fully successful |
1 | Complete each |
1 | 12 Points |
1 | If your submission is |
1 | Correct Style Zero style errors, |
1 | Any style errors present, |
1 | Proper programming |
1 | If your code follows all |
1 | Unacceptable |
1 | Significant issues related |