CS 115 / IT 115 Java Programming 2

Programming Assignment 2

For this assignment, we will work with the SysInventory program we are/will be discussing in class; see the provided files.

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.

 

  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 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, no move later, 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

 

  1. 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.


Create a subdirectory p2 (not P2) in your it115 subdirectory on your CS Unix network account, and transfer a copy of your resulting Java files and narrative there, in plain text file memo.txt

Delivery files: Make sure the names are the same as specified here, including their case (Not Memo.txt for example)

1.      ITSystem.java  with added toString() method, and possibly another method.

2.      SysInventory.java with added code as specified above. Make helper methods so as to avoid duplicating code.

3.      SystemInventoryMain.java: needs no change.

4.      memo.txt, with interactive tests shown.