CS111 PreLab2

This prelab consists of three parts which should all be completed before lab. Everything should be done with pen and paper. Use of a computer is not required. If you have a lot of difficulty with this prelab, you can visit the drop-in tutor on Sunday 7-9pm in E101. Please keep track of the amount of time you spend doing the prelab. Prelab solutions will be discussed at the beginning of lab. Solutions will not be handed out or posted. If you want the solutions, come to lab (or ask your classmates afterwards)!

Note: Students who miss lab due to Yom Kippur may ask for a copy of the solutions and may make arrangements to discuss what we go over in lab.

Part 1 -- Types of Methods

In lecture we learned about void and non-void methods and about methods with and without parameters. For the first part of the prelab, you should look at the Buggle Contract and sort all the methods in the five different classes (Buggle, BuggleWorld, Point, Color, and Direction) into the four possible categories. For non-void methods you should indicate what type of data it returns. For methods with parameters you should indicate what type of parameters it takes.

Print out (or copy) the sample chart. Some of the methods have been placed in the proper categories to get you started.

Part 2 -- Using Methods

In lecture we learned about methods and how to use them. Write the code for each of the following requests as one statement.

Optional: You may choose to test your answers by downloading the CS111PreLab2 files from the /usr/users/cs111/download/labs_morning directory on nike.wellesley.edu and editing the CS111PreLab2.java file. To see your results, run the CS111PreLab2.html file from AppletViewer.

	// Create new Buggle barb



	// Create a new point school at (5,2);


	
	// Create a new color barbBlue which is two times darker than Color.blue
	// (use the darker method of the Color class twice)	


	
	// Set barb's color to her favorite shade of blue (barbBlue)


	
	// Set barb's position to be at school



	// Create new Buggle ben



	// Set ben's color to one shade brighter than barb's favorite shade of blue



	// Move ben to be in the same position as barb's position (use getPosition)


	
	// check, are ben and barb in the same position (store in variable sameDirection)



	// check, what direction is ben facing? (store in variable benDirection)
	
	
	

Part 3 -- Statements and Expressions

In lecture, we learned about statements and expressions. Identify the statements and expressions in the code you wrote for Part 2 above. Underline each expression and circle or box each statement.