Review for the Final Exam

 

You need to know:

 

Robust
class methods

 

 

You will be able to look at your BlueJ programs for the short-response section.

It will be based upon Turtle and Vic.

It will ask you to interpret code as well as find mistakes in a sample of code.

 

 

You must also know basic java terminology as well as programming concepts.

For example, know what it means to:

-         Declare a variable

-         Initialize a variable

-         What is a class?

-         Where do objects come from?

-         Why are constructors necessary?

-         How to write a for loop.

-         How to write an if statement.

-         Be able to look at code and understand it.

 

 

There will be a programming section at the end based upon the “Person” class demo we did in class.  You will need to be able to create a class from scratch based upon information given.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Part 2 --Programming 40 points

Read all instructions carefully before beginning.  You will be writing and documenting a subclass of Vic, writing an application program for testing that subclass.  In addition to the correctness of the code, you will be graded on style and documentation as follows.  If you get stuck on an error or can get by a certain point, I will sell help for 1 point per question.

 

________(5) Style throughout

 

________(3) Class Documentation (at top)

 

________(7) Method Documentation (above each and inline as needed)

 

You have a Final Exam folder in your Java1 folder.  There is a VicWorks project (The Coin project is extra credit, see below.)

 

In VicWorks, create two new classes, RobustVic and VicTest.  RobustVic is a subclass of Vic and VicTest is an application program to test your RobustVic methods.  Remember that many commands can cause errors if the Vic is on END when they are executed.

Write these methods so they cannot fail

(3 points) public void moveOnRobustly() (should do nothing if the Vic is on END)

(4 points) public void takeCDRobustly () (should only take a CD if there is one)

(4 points) public void putCDRobustly () (should only put a CD if there is one in the stack and the present slot is empty)

(4 points) public boolean seesCDRobustly () (a boolean method that makes sure there is a slot before looking)

           (10 points) Write a main program in VicTest that will check each of the above methods, make sure you show your test data in the comments and show all tests.  You may comment out // a test after it is working so you don’t have to wait through so many.

 

EXTRA CREDIT

(10 points) Create a CoinTest class and write an application program to play the following game (you will make a bet of $1 and every time you get a head, your winnings double, but if you get 3 tails in a row you lose)

            create a coin

            make a boolean variable win and set it to true

            make an integer variable tailsInARow and set it to zero

            make an integer variable bet and set it to 1

            in a loop flip the coin 10 times

                        print out if it is heads or tails

                        if it comes up heads

double your bet

set tailsInARow to zero

                        else

add 1 to tailsInARow

check if tailsInARow is 3

            set a win to false

            print out the results.  Copy the output for both a winning and losing round under your main.