Java代写:CSE174_Assignment4

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:

  1. The length of methods (including the main method) should be less than 35 lines.
  2. 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
2
Successful
submission via Code
1
2
3
4
5
A fully successful
submission to CODE
that passes all tests will
earn full credit.
60 Points
1
2
Complete each
test.
1
12 Points
1
2
3
4
5
If your submission is
not accepted by
code, you will
receive no credit.
0 Points
1
2
3
Correct Style Zero style errors,
will earn full credit.
10 Points
1
2
3
Any style errors present,
you will receive no credit.
0 Points
1
2
Proper programming
practices
1
2
3
4
If your code follows all
acceptable practices,
you will earn full credit
30 Points
1
2
3
Unacceptable
code gets partial
credit.
1
2
3
4
Significant issues related
to programming practices
will earn no credit.
0 Points