600.108 Intro Programming Lab, Week 1

Lab Course Introduction:

[20 min] See the course website at cs.jhu.edu/~joanne/cs108 for important course policies regarding attendance and grading.

This lab course will be run using the paired programming software development technique. This means you will work with a partner each week. At any point in time during the session, one of you will be acting as the "driver" - hands on the keyboard typing out that solution part. The other one will be the "navigator" - looking out to tell the driver what to do and where to go next. Throughout each lab session you must switch roles where indicated. Let's start by getting partners as follows: those enrolled in this section will work with people in this section; those not yet enrolled or from another section should then find similar partners.

Since we've only had two lecture classes so far, and we are assuming you have not programmed (significantly) in the past, lab this week will require lots of assistance from the lab leaders. They are a great resource for you, so don't be shy about asking for help! This will definitely be a learn by doing session.

The first part of lab each week will be a brief "quiz" and review to reinforce concepts. Log into blackboard, go to "Quizzes" and take the "week 1 survey".

The Problem: HI-LO GAME

Write a program to play the hi-lo game which proceeds as described here. The user is expected to guess a number. After each guess, the program outputs whether the guess is too high, too low, or correct. The user only has 6 tries to guess correctly. A game is over when the user guesses correctly, or runs out of guesses. Once a game is over, the user can quit or play again. When the user quits, the program should output the percentage of how many times s/he won.

Step 1) ANALYSIS: [30 min] Using Word (or any text editor), create several sample runs to show the user interface of the program and possible input/output scenarios, similar to the example(s) we did in class. In other words, what you do expect to see on the screen when the program runs? What are possible inputs and corresponding output messages? Play the game a few times, making up examples to show sucesses and failures. Ask a lab leader if the problem needs clarification. Make sure a lab leader approves this stage before you start the next phase.

--- Switch driver/nagivator roles ---

Step 2) DESIGN: [30 min] Create a text file with a pseudocode solution. Ask your lab leader for help if necessary. Remember to make it sufficiently detailed and unambiguous. But DO NOT write actual program code. Show your pseudocode to your lab leader for approval. Rework as necessary.

Step 3) More design: [10 min] You will then receive cut-up pseudocode (sort-of like a puzzle) that needs to be arranged into the proper order. The real Java program code will be on the reverse side. Once you have arranged the pieces of pseudocode, show them to your lab leader for verification of correctness.

--- Switch driver/nagivator roles ---

Step 4) CODING: [30 min] The (new) driver should open jGRASP. For this week, type in the Java code that was given to you with the pseudocode (viewable at http://www.cs.jhu.edu/~joanne/cs108/hi_loBAD.java). Save this with filename HiLo.java, and compile your program periodically as you type. There will be several compiler errors once you've finished typing the program as given. Do your best to fix them yourselves, then ask a lab leader for help. Let a lab leader know when you have it compiling.

--- Switch driver/nagivator roles ---

Step 5) TESTING & DEBUGGING: [30 min] Make up a large test suite of sample runs. There are a few more mistakes in the program that won't show up until you test it thoroughly. Write down the sample inputs that cause problems and try to fix them. Show a lab leader what you've done and get help as needed.

Step 6) CLEAN-UP: [10 min] Return the pseudocode "puzzle" to a leader (make sure all parts are in the envelope). Zip all the files together from today's lab and email to both students. Then each student must submit their work on Blackboard for the week, noting their partner's name and JHED login in the submission textbox. You must then delete your files off the lab computer and logout before leaving! Failure to do so constitutes an ethics violation.