Homework 3


The last assignment has two different projects associated with it. You will be required to hand in multiple files, so please double check that you have submitted everything necessary.

Grading for these exercises will be based on completion of the exercise, which includes creating the requested additional commands. There will also be some points awarded for organization of code, style of code (correctly indenting, and bracketing), and commenting of code. Comments should describe the purpose of each service / method / function that you create, as well as your approach to solving the logic of putting those services together. Each code file should start with a comment with the names of all team members.

Details


Guessing Game Program


For this program, you and your team will create a non-robotic program wherein the user tries to guess a secret number that the program chooses. You’ll use the provided files, Game_Program, and GuessingGame, as the starting point for your program.
When the program starts up, it should print a message welcoming the user to the game, and then start the game. The game should start by printing a set of directions, and then asking the user for the user’s first guess. The user only gets 5 guesses to guess the secret number. If the user guesses the secret number, then a “You’ve won!” message is printed to the screen, and the game ends. Otherwise, the program tells the user if the guess was lower or higher than the number. The program should keep track of the numbers that the user has guessed (using an array), and print them all out before the user guesses. If the user guesses something they’ve already guessed, don’t count it as a guess, but do print a message politely reminding them of this. You need to tell the user how many guesses they have left at each step. If the user runs out of guesses, the program should tell the user that, then print the secret number, and then the game ends.

Once the game has ended, the user should be given the choice of whether to play the game again. This answer should be given back to the Game_Program’s main method (as opposed to having another loop inside the GuessingGame object).

An example transcript demonstrating how the program might run is as follows (player input is in bold)
Welcome, new player! Let’s play the guessing game!
Rules of the guessing game:
1. You’ve got 5 guesses to guess my secret number
2. The number is a whole number that’s between 0 and 15 (inclusive at both ends)
3. I’ll give you hints about the number, if you don’t guess right.


Ok, I just thought of a new number for you to guess.

So far, you’ve guessed:
You have 5 guesses left
Your next guess?
7

I’m sorry, but my secret number is not 7, my secret number is less than 7
So far, you’ve guessed: 7
You have 4 guesses left
Your next guess?
7

You’ve already guessed 7, so far, you’ve guessed: 7
You have 4 guesses left
Your next guess?
5

I’m sorry, but my secret number is not 5, my secret number is greater than 5
So far, you’ve guessed: 7 5
You have 3 guesses left
Your next guess?
6

Great guess!!! That’s my number!! You _SOO_ win!!
Want to play again (type 1 for “yes”, and 0 for “no”)
0
Have a nice day!

Histogram Program


Writing A Program: Histograms!

A histogram is a type of bar chart that's used to display a collection of numbers. While most of the histograms are drawn vertically, we're going to draw a histogram horizontally. For this assignment, you will get a robot to draw a (horizontal) histogram of Things. For this part, you will need to use the DrawHistogram file that is provided to you on the website.

Let's say that the histogramData array contains the numbers [3, 5, 1, 0, 4, 2, 1] You need to add code to main so that the robot would produce a histogram like the following:

Notice that the first element in the histogramData array ( element histogramData[0] ) has the value 3, and that the first (top-most) horizontal bar is 3 Things wide. The second value in the array is 5, and the second row contains 5 Things, and so on. Note that in order to get full credit, you must implement (and use the DrawRow) method on the robot, which will put down all the Things for 1 row, and then return the original starting location. You're welcome to put everything else for this part of the assignment in main.