First, if you have checkpoints left over from last lab, get them inspected during the first 15 minutes of this lab. No credit will be awarded past these 15 minutes.
Don’t forget to work in pairs! Where possible, please work with someone that you did not work with last lab. The exchange of new ideas and perspectives is not an opportunity you want to rob yourself of.
In this lab you will learn about bundling data and its related code into objects. Large software is built out of hundreds of interacting objects, each of which is managing a small chunk of an otherwise overwhelming task.
Solve the following problems:
Points. Include the following:
Point‘s initial x- and y-coordinates.
toStringmethod that returns a String of the form
scalethat accepts a scale factor parameter. Scaling multiplicatively extends or shrinks a a
Point‘s distance between the point and the origin.
translatethat accepts x- and y-offset parameters. Translating shifts a
Pointby the offsets.
rotatethat accepts an angle parameter. We won’t derive the formulas for rotation here. The new coordinates can be found with the following expressions:
rotatedX = x * cos angle - y * sin angleand
rotatedY = x * sin angle + y * cos angle.
Now write a main method that produces a spiral. Construct a point (not at the origin), and repeatedly rotate and scale it. After each transformation, print it to the console, separating each
(x, y) with a comma. Paste the result list into Desmos.
RoundRobinthat can be used to fairly distribute responsibility among a group of individuals. It manages rotating through the group. Include the following:
addmethod that accepts as a
Stringthe name of someone to add to the group. When added, the person should be queued such that they will be chosen as the next responsible.
sizemethod that returns as an int the number of people in the group.
rotatemethod that returns as a
Stringthe next responsible person. This person becomes the least responsible, while the person just “behind” is the next responsible.
Also write a main method that constructs a
RoundRobin, adds some names, and rotates through it a few times. Print the names of the responsible parties.