Comp 101 Lab4:kids passing notes.
Due at 11:59pm On Mon Oct 27th Wed Oct 29th
In this program you will write a program that will act as a note
passing gradeschooler. You may remember (even if you wish you didn't')
the grade school tradition of sending notes with "do you like me yes
no" to classmates for them to select one of yes or no. Its time to
bring that tradition into the digital age in case todays students
haven't done so already.
- write your own main method
- read input from the user
- using selection statements.
collect the starter zip file as follows:
cp ~jsantore/Lab4Start.zip .
unzip the file as usual and move into the Lab4 folder. You'll see that
there are two java files for you, one NoAnswer.java and one called
YesAnswer.java. There are also a few image files in the folder that the
java files that I provided will reference.
First create a class, Name it what you want, but make sure you follow the class naming conventions.
in that class you will need 4 methods
- the main method - all main methods have the same method
declaration - which you have seen in chapter 1 of your book. The method
body of this method should have only two lines (three if you use the
JOptionPane to get user input.) It needs to create an object of your
class then call the askUser() method from your class on that object.
- askUser(): Your class needs to have a method called askUser, this method should have code which does the following:
userSaidYes: in this method you need to create an object of my
YesAnswer class and call the method called showYes on your YesAnswer
object. The YesAnswer constructor takes no parameters. The showYes
method takes no explicit parameters and returns no value.
userSaidNo: in this method you need to create an object of
my NoAnswer class and call the method called showNo on your
NoAnswer object. The NoAnswer constructor takes no parameters. The
showNo method takes no explicit parameters and returns no value.
Then compile your file, (remember javac YourClassName.java) when there are no errors, run it (java YourClassName)
- asks the user the question: "Do you like me?"
- retrieves the user's answer to the question (use any method we have discussed in class)
- uses selection
- if the user answered yes, then call your class's method called userSaidYes
- if the user answered no, then call your class's method called userSaidNo
Make sure everything works, if you answer no, your program will be sad,
if you answer yes, your program will be happy. I'll let you find out
what the results look like on your own when you have a working version
of the lab.
You are writing code in a creative way for the first time (its the
first time that I've not told you more or less in English what to
write, instead you are deciding how to do things) So commenting becomes
much more important. Remember to explain what you are doing. There will
be some credit given for commenting your code.
When you submit this time, add a readme.txt file to your Lab4 folder
that you are building. (In xemacs you create a new file by doing
<file><open file> and typing in a brand new file name. The
readme should contain:
Once you have the readme done, cd into your parent folder, zip up the
entire Lab4 file
name. If you used konqueror to zip up the file, use konqueror to rename
to file to include your last name. for example I would use:
- Your name.
- A very brief summary of what you did
- A list of any problems still in your code or anything that you didn't get done.
Once you have the zip file, use the online submission program to submit it to me.