Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A bonus homework assignment for a java programming class, where students are required to write methods to draw their initials using the letterturtle class. The assignment includes instructions on handling repeated letters and drawing shapes, as well as important notes on method headers, creating a world, and hiding letterturtles. The deadline for submission is june 8, 2008.
Typology: Assignments
1 / 2
DUE DATE: Sunday June 8, 2008
For this bonus assignment, you will be required to draw the first letters of your first, middle, and last names in a class called LetterTurtle(start with the provided LetterTurtle).
You will be expected to draw the first letters of your first, middle, and last names, which will henceforth be referred to as your initials for the purposes of this homework. For me, Katie Anna Long, this means that I should draw the letters “KAL” to receive credit. If your initials contain multiple instances of the same letter, you must instead choose a short word that has atleast three different letters in it (such as EAT, ISYE, or SET). If your initials have no repeated letters, you must write your initials.
We realize the difficulty of creating letters that have curves such as D, O, S, B to name a few. Those with initials that have curves may draw the “block” or “square” versions of the curved letters instead.
You must write a separate method for each letter. The methods should take in a starting integer x coordinate and starting y coordinate. How the starting coordinates will correspond to your letter is up to you, but will need to be detailed in your comments. The minimum requirement will be for both methods to be void, but non-void methods are also acceptable.
For example, the methods I would have to write would be something akin to the following:
public void drawK(int x, int y) { //Method body in here }
public void drawA(int x, int y){ //Method body in here }
public void drawL(int x, int y){ //Method body in here }
You will be required to draw your letters on a World (similar to what we did for the in- class TurtleToys class). To write your initials at specific coordinates, look in the SimpleTurtle class for a constructor that takes in two integer coordinates and a Picture (this will be your World). o Hint: You might find it useful to create a different Turtle for each letter. To make the drawing easier to see, you need to change the Pen width of the LetterTurtle to something other than the default width of 1 (look in the SimpleTurtle class to determine how to do this). The final resulting drawing cannot contain any visible LetterTurtles (look in the SimpleTurtle class to determine how to do this). Be sure to include a main method, such that when I type ‘java LetterTurtle’ in the interactions pane, a world pops up that displays your initials (or a short word, in the case where one of the letters in your initials is repeated).
This homework is extra-credit (although not necessarily worth a full homework), and hence is not required. If you’re code does not compile, you will receive a zero for the assignment Make sure to turn in the .java file, NOT the .java~ or the .class files You must comment your code (you will lose a substantial number of points if you do not) You will lose points if you do not put your name, T-Square log-in, and a collaboration statement at the top of all files.
LetterTurtle.java