Problem #1
- Given two method parameters both of type Point: p1 and p2
- Given a third method parameter of type int named k
- Send the message multiply to the first point with the other point as a method parameter, and assign the result to a var named p3
- Now send multiply to p3 but do not use a Point object as the method parameter (use another var you have available), and assign the result to a var named p4
- Return p4
Problem #2
- Given method parameters elli of type Ellipse, g of type Graphics and color of type Color
- Send the message drawOn to the Ellipse object
- Return the Ellipse object
Problem #3
- Given method parameter named circ of type Circle
- Construct a Point object with x = 100 and y = 50 (use any var name you like)
- Send the message moveBy to the Circle object passing the Point object
- Return the Circle object
Problem #4
- Given method parameters space of type OuterSpace and p of type Point
- Send any message (coder's choice) to space and assign the return value to a variable named z of type int
- Return space
Problem #5
- Given method parameter space of type OuterSpace
- Send a message to space passing two int parameters 100 and 75
- Return space
Problem #6
- Given method parameters ellipse of type Ellipse and frame of type Frame
- Send a message to determine if frame contains ellipse
- Assign the result to a var named result
- Note that you may use shape boundaries as a good enough estimate for the contains check
- Return result
Problem #7
- Given method parameters circ of type Circle and ellipse of type Ellipse
- Determine if the circ and ellipse intersect and put the result in a var named result
- You may use shape boundaries as a good enough estimate of intersection
- Return result
- Hint: You may want to declare and use a couple more vars
Problem #8
- Given method parameters fw of type ForwardIndicator, and x and y both of type int
- Send the message conformX to fw with the correct parameter and assign the result to a var x2
- Send the message conformY to fw with the correct parameter and assign the result to a var y2
- Construct a var p of type Point
- Send the appropriate messages to the var p so that you set the point's x and y with the x2 and y2 vars
- Construct a var elli of type Ellipse
- Send the message setAnchor to elli using a var you have available
- Send the message setLongDimension to elli using a value of your choice
- Return elli
Problem #9
- Given method parameter frame of type Frame
- Construct a var named leftTop of type Point
- Set the x value in the point to the Frame's left value
- Set the y value in the point to the Frame's top value
- Return leftTop
Problem #10
- Construct a var named p of type Point
- Set the x value of p to 123
- Set the y value of p to 405
- Then declare a var niceString of type String
- Choose a message to send to p and assign the result to the var niceString
- Return niceString
Problem #11
- Given method parameter frame of type Frame
- Construct a var named circ of type Circle
- Send the message setAnchor to circ using the middle of frame
- Send the message setLongDimension to circ using the width of the frame
- Return circ
Problem #12
- Given method parameters circ type Circle and p of type Point
- Move circ by p
- Return circ
Problem #13
- Given method parameters frame of type Frame and x of type int
- Assume the param x is the x value in a coordinate
- Return true if frame contains x (otherwise return false)
Problem #14
- Given method parameter frame of type Frame
- Construct an Ellipse named ellipse
- Set the anchor of ellipse using the middle of frame
- Set the longDimension of ellipse using the height of frame
- Return ellipse
Problem #15
- Given method parameters space of type OuterSpace and p of type Point
- Send a message to space that will set it's rate using the points x and y values
- Return space
Problem #16
- Given method parameters frame of type Frame and p of type Point
- Return true if the frame contains the point's y value (otherwise return false)