need help with Java programming

Oct 27th, 2015
SoccerBoss
Category:
Calculus
Price: $35 USD

Question description

Most of the project is complete. 

I need help with step 5.

Step 6 is done, however, I made a mistake that I cannot solve, the output says There are 4 systems and my output says There are 5 systems i cannot find this minor error.

Note: in the examples I show the output you should get for the given input. If your output does not match this for the same inputs you will receive less credit. For example, after a move command you should display the number of the old room, the systems in the old room, the number of the new room, and the systems in the new room, in the format shown. Output format and details are less important then getting your logic correct and getting the program to work, but they are still important.

For this assignment, we will work with the SysInventory program we are/will be discussing in class; see the provided files. In the linked directory you should find: ITSystem.java, SysInventory.java, and SystemInventoryMain.java 

Here is a run of the provided system. Output like this is what I mean by the results of “interactive tests”.

Welcome to Departmental Network Systems

Enter how many systems: 2

Enter the system's room no: 10

 System is assigned number 1

Enter the system's room no: 20

 System is assigned number 2

Enter system inventory number, 0 to quit: 2 <-- for #4 Enter id number or room number preceded by “room”

System 2 selected

Actions: exit, help, print, record-problem

Enter action: print

ITSystem@1a758cb <-- note useless toString() output: fix this in #1.

Enter action: record-problem

The system now has 1 recorded problems

Enter action: help

Actions: exit, help, print, record-problem

Enter action: exit

Enter system inventory number, 0 to quit: 0

Goodbye from Departmental Network Systems

  1. Add method toString() to ITSystem, including information from all fields. After this, the “print” command should work better in SysInventory. For this part, you only need to edit ITSystem.java, then rerun the whole program to see the improved output. As an example of what should be displayed for the print command issued above (associated with system 2 in the example):

Enter action: print

 Id 2 room 20 problems 0

Enter action:

  1. Modify processActionsForITSystem() so as to add a  “in-same-room” action. It should print out all the systems in the same room as the currently selected system, using toString() to print out one system. Devise a series of (interactive) test inputs to exercise your program fully.

After this edit, the system should run (after same setup, so only one system in the same room):

Enter system inventory number, 0 to quit: 2 

System 2 selected

Actions: exit, help, print, record-problem, in-same-room

Enter action: in-same-room

 Systems in the same room as system 2:

 Id 2 room 20 problems 0 (toString output for system 2, can be different in detail)

Enter Action: …

This can be one “interactive test” result, but clearly we need to test with multiple systems in the same room for full testing.

  1. Modify processActionsForITSystem() so as to add a “move” action. It should prompt for the number of the room to which the system is being moved, and print a warning if the room is the same as before. You may want to add a method to ITSystem for this. When complete, print out all the systems now in the old and new rooms. Devise a series of (interactive) test inputs to exercise your program fully.

Enter system inventory number, 0 to quit: 2 

System 2 selected

Actions: exit, help, print, record-problem, in-same-room, move

Enter action: move

 Enter room for system 2 to move to: 10

 Systems now in old room 20:

 None

 Systems now in new room 10:

 Id 1 room 10 problems 0

 Id 2 room 10 problems 0

Enter Action: …

  1. Currently the user needs to know the id number to work on a system. Modify whichITSystem to allow the user to alternatively enter a room number, by entering “room 22” for example instead of just “12” for system 12. If there are multiple systems in that room, print them out and then ask for the id, and return from whichITSystem with the selected ITSystem object, as in the unmodified case. 

In the case of the original setup (without moves) the room number simply specifies a system, like this:

Enter system inventory number, 0 to quit, or room <n>: room 10

System 1 selected 

Actions: exit, help, print, record-problem, in-same-room, move

In the case of the original setup followed by the move specified above in 3, the room number selects 2 systems, and we need the user to choose between them, like this:

Enter system inventory number, 0 to quit, or room <n>: room 10

Room 10 has 2 systems:

 Id 1 room 10 problems 0

 Id 2 room 10 problems 0

Enter system inventory number from above list, 0 to quit: 2 

System 2 selected

Actions: exit, help, print, record-problem, in-same-room, move

5. Systems don't start out with problems, but develop them over time. Suppose a repairman comes in and wants to know all the systems that have problems. Modify whichITSystem to all the user to alternatively enter a display-problem-systems command. If so, print all systems with problems like this:

Enter system inventory number, display-problem-systems, 0 to quit, or room <n>: display-problem-systems

 None 

Enter system inventory number, display-problem-systems, 0 to quit, or room <n>: 

After the user has recorded 1 problem for systems 1 and 3 (in room 30) but not 2:

Enter system inventory number, display-problem-systems, 0 to quit, or room <n>: display-problem-systems

Id 1 room 10 problems 1

 Id 3 room 30 problems 1

Enter system inventory number, display-problem-systems, 0 to quit, or room <n>:

6. Write a narrative that describes how you went about designing and implementing these modifications, how you tested your program (how test cases were chosen and why) and a (cut and pasted) result for these tests. Put this in a text file called memo.txt.

Extra credit: the user might want to know all the systems that exist. Modify whichITSystem so as to add a “print-all” action to print out all the systems that exist (using toString() to print them out). This action should only be available at the “Enter system inventory number” prompt, as the user should not be required to enter the system number to see what systems exist. You might want to create your own method for this that gets called from whichITSystem. The command should print the systems out in order of the room number they are in (lowest to highest). For systems in the same room you can print them out in any order. You can do this in similar manner to the one in AutomobileMain.java, where first the Automobile objects are sorted, and then printed out. You will also have to implement a compareTo function in ITSystem.java, and make the ITSystem class implement the Comparable interface, very similarly to how Automobile.java does this. Note that the systems in the array start at index 1 and are ordered by system id, not room number. This causes two types of problems: first, the sort method for arrays requires that data start at index 0 of the array; and second, if we sort the data in the array, modifying it so the array is no longer sorted by system id, other code in the program will break. In order to get Arrays.sort to work, and not to change all the other code you may want to create another array of ITSystem, just for this problem, which should start at index 0. If so, copy the standard ITSystem array to this new one, (but going from index 1 (old) to index 0 (new), index 2 (old) to index 1 (new), etc), and then sort the new array before printing it. Modify your narrative to include this problem as well. The interactive test might look like this:

Welcome to Departmental Network Systems

Enter how many systems: 4

Enter the system's room no: 10

 System is assigned number 1

Enter the system's room no: 10

 System is assigned number 2

Enter the system's room no: 5

 System is assigned number 3

Enter the system's room no: 2

 System is assigned number 4

Enter system inventory number, print-all, display-problem-systems, 0 to quit, or room <n>: print-all

There are 4 systems

 Id 4 room 2 problems 0

 Id 3 room 5 problems 0

 Id 1 room 10 problems 0

 Id 2 room 10 problems 0

Enter system inventory number, print-all, display-problem-systems, 0 to quit, or room <n>: 0

Goodbye from Departmental Network Systems



Tutor Answer

(Top Tutor) Daniel C.
(997)
School: Boston College
PREMIUM TUTOR

Studypool has helped 1,244,100 students

Summary
Quality
Communication
On Time
Value
tinytim47
Feb 17th, 2017
" Wow this is really good.... didn't expect it. Sweet!!!! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1825 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors