COMP 110-001: Introduction to Programming, SSI'15
Lab 3
25 points
Assigned: Wednesday, May 20, 2015
Due: Friday, May 22, 2015 by 11:59pm (EDT)
Description
Lab 3 will introduce you to Java applets, flow charts, and if-else statements. You have been given a skeleton program SmileyFace.java that can be found on the course webpage. Copy the program into Eclipse, and compile and run the program. When you run the program you will have to input a String before you will see the Java applet appear. (You will use this input for part 2)
Part 1
At the beginning of the program you will notice that there are many Named Constants. Notice that the identifiers are in ALL_CAPS. Go ahead and change the values of some of the Named Constants and recompile to see what changes you have made to the program. Make sure to change the constants back to their original values before continuing to part 2.
Part 2
For this part of the lab you will modify the code SmileyFace.java so that is follows the flow chart.
The flow chart may look daunting so take it one branch at a time. Take a look at the code that has been given to you and pay attention to the comments about where you should start to write your code. You do not need to change any part before or after the comments. The code that reads in the user input (as a String) has been already provided, so what you need to do is to write the multibranch if/else statements. Also, the variables you will play with are mouthStartAngle, noseDiameter, and eyeColor. Do not worry about error checking. If the user inputs the incorrect thing, the original smiley will display without any changes.
Start to play with changing the MOUTH because it is the easiest one.
Grading
- 5 points MOUTH
- 10 point NOSE
- 10 points EYES
How to hand in the assignment
- Create a file named yourlastname_lab3.jar, where yourlastname is your last name.
The .jar file should include SmileyFace.java and SmileyFace.class.
Your java file should have the appropriate header.
- NOTE: Follow these instructions to create yourlastname_lab3.jar, but you do NOT need to create a MANIFEST.MF file for this lab. Start from the third step. On the last page of the jar file Export in Eclipse, simply select "Generate the manifest file" instead of "Use existing manifest from workspace"
- To ran this jar file, we need to use AppletViewer, because it is an Applet, not an application. It runs on Web. Copy this webpage jarApplet.html and save it in the same folder of your jar file. Change "hong_lab3.jar" in jarApplet.html to the name of your jar file. Then go to the directory (using cd command line) where you saved your jar file, and type "AppletViewer jarApplet.html". You will see the smiley face. This is a little complicated, but I suggest you to have a try, especailly for cs students, because it is how to deploy an applet. If you have difficulties to run the jar file, just submit the jar file, or you can also submit your Java files (.java and .class).
-
Submit yourlastname_lab3.jar or (.java and .class files) via Sakai by 11:59 pm Friday, May 22.
-
If you do not follow these instructions you will not get credit for the lab. Please let
me know if you are having any problems with the lab and the assignment submission process.