CS 161 Homework 1 - Chattybot

Due Fri Jan 30 at 11:59pm

Overview

In this first assignment, you will be programming some behavior for a chatty virtual robot. You will be filling in methods that give the robot the ability to "speak" by printing text to the BlueJ Terminal. This will give you practice with the "code/compile/test" cycle for developing software, as well with printing and working with Strings of text.

This assignment should be completed individually (not in pairs). If you get stuck please ask me for help. You can also ask questions of your classmates, but remember the Gilligan's Island rule!

Objectives

Necessary Files

You will need to download the Hwk1.zip file, which contains the BlueJ project for you to complete. Remember to unzip the contents from the file!. You should save the unzipped project to your Alexandria drive for safe-keeping.

The project contains one class: Chattybot. The class has a number of methods declared, but they currently are empty and don't do anything. You will need to fill in their functionality.

If you haven't yet, you will also need to download and install the BlueJ IDE

Assignment Details

Again, as we're just getting started I'll help walk you through the steps to complete this assignment. Be sure to read the instructions carefully--they contain all kinds of good advice!

Setting up the BlueJ Terminal

Before you begin, you'll want to make sure that BlueJ is configured to work properly for this and future assignments. In particular, you'll want to make sure that the Terminal is behaving correctly.

Writing Code

The rest of the assignment involves filling in methods in the Chattybot class. Double-click on the orange Chattybot box to view the source code. You will be writing Java code in here.

Remember: write one method at a time, testing as you go. Complete a method, then run your program to make sure it does what you expect! You can run your program by following the below algorithm:

  1. Click the "Compile" button to compile your source code
  2. If there are any compile errors (and there often are), you will need to fix them. Go back to Step 1
  3. Right-click on the orange Chattybot class and select new Chattybot(). This will create a new Chattybot for you to interact with.
  4. In the workbench, right-click on the red Chattybox object to select the method you wish to call.
  5. Call the method and look at the output. Does it do what you expect?
  6. If it doesn't, there is a logical error--go back to the source code and modify it make the code do what you want. Then return to Step 1.
  7. When everything works, go on to the next method

Get used to this "debugging cycle"; we'll be doing it a lot throughout the class! Remember that each step is important--particularly Step 6 (checking that it works as you expected).

Chattybot's Methods

You will need to add functionally to the following methods in the Chattybot class:

There are quite a few methods to write for this assignment! However, each should only be a few lines of code--try to do one or two each day and you should be fine.

Submitting Your Assignment

There are a couple of details to keep in mind before you submit your assignment.

  1. Make sure your Chattybot program works--you should be able to call all the methods and get the desired output. Make sure you can call them one after another and everything works.
    • If your program doesn't compile, I can't give you credit for it!
  2. You will also need to fill out the README.txt file. You can open this file in BlueJ by double-clicking on the white paper icon in the upper left corner of the class window. You should place the answer to each question below the question box, replacing the "<Replace this with your response!>". Remember to save your changes (select "Class > Save" from the menu).

  3. You should compress the entire Chattybot folder into a single zip file (like you did for Lab A), and then submit it to the Hwk1 Submission page on Moodle.
    • Be sure an upload the ENTIRE Chattybot folder--that is what includes all your work! The "package.bluej" file is deceptive--it isn't actually the project or package, just a file that is used to open BlueJ! If you just give me that file, I won't be able to see your work.
  4. This assignment is due at midnight on Fri, Jan 30.

Grading

This assignment will be graded out of 12 points: