JAVA 1 – First Quarter Exam – PROGRAMMING TEST
GENERAL
INSTRUCTIONS:
Please read the directions carefully and refer back to them frequently while writing your program. You will be given points for each test data that works. The program should be robust. (It should not give an error message or take CD's from the stack that it did not put there). This is worth 20 points.
YOUR TASK:
test data – Try these arrangements to test your code. 0010 (good) 0000 0001 0011 001
Write an application program that creates a SmartVic who moves
a CD from slot 3 to slot 4 robustly. If there is no CD in slot 3, it should do
nothing. If there is a CD in both places
originally, it should replace the one in 4 with the one in 3.
THE
PROCESS:
Create a new application class, TWYourLastName,in your VicWorks folder. e.g. TWSmith
Create a SmartVic
Have the SmartVic move the CD from slot 3 to slot 4. good test data ("0010" -> “0001”)
If there is no CD in slot 3, it should do nothing. ("0000" -> “0000” ) and (“0001” ->”0001”)
If there is already one in slot 4, replace it with the one from slot 3. {“0011” -> “0001”} which is with CD names {"00c1d1" -> “000c1”}
If there is no slot 4, do nothing. {"001" - > “001”}
Extra Credit: Write and use a SmartVic method, public void returnToFirstSlot (int presentSlot), that will move a SmartVic from its present slot back to slot 1. Use this method in your main program to leave the SmartVic on the first slot after it has shifted (or tried to shift) the CD.