KIT 101 Programming Fundamentals Solved

$ 29.99
Category:

Description

PP Task 2.1 Turtle Graphics

Overview

Purpose:
Task: Use the methods of an existing object to customise one graphical program and then develop your own.
Complete the three tasks of: customising an existing Turtle Graphics program; writing the algorithm for a Turtle Graphics program that draws your initials; and then implementing that program
Learning Outcomes: 1 @ 3 ‘
Time: Start during your Week 2 tutorial and submit before Week 3.
Resources: • Introductory Programming Notes:
0 03 Problem Solving with Computers 0 05 Using Objects o KIT 1 01 Support Library API Documentation
Online Mini-lectures:
Solving Problems with Computers:
• *Algorithms
* Importing & using objects
Some commonly used objects
Submission Details
Upload the following to the MyLO submission folder for this task:
Your modified RainbowTurtle.java source file
A screenshot of the RainbowTurtIe window when running
A Word document or PDF of your algorithm for writing your initials using a Turtle Graphics object Your completed Initials.java source file
A screenshot of your Initials program when running
Assessment Criteria
A Completed submission will:
• Exhibit good code style by matching the provided code’s layout and indentation
• Have your name in both source files in the comment at the top, following the text @author
• Compile and run, with the screenshots showing both programs working
• Have each shape in RainbowTurtle appear in a different colour
• Include an algorithm using the Turtle Graphics commands of penup, penDown, turn and move (and optionally origin and setColor) that will draw your initials
• Show that the Initials program implements that algorithm and draws your initials
Instructions

In this task you’ll use a turtle graphics system to draw some simple images. Turtle graphics is based on the idea of a drawing device (the turtle) that sits on top of a flat drawing surface. In a typical turtle graphics system, the device can be instructed to raise or lower its drawing pen, rotate counter-clockwise by a specified amount and to move forward by a specified number of units.
Tip: Any link I provide to Wikipedia is optional and included for your interest only. Any essential information will be given here or in the accompanying notes and lectures (or in online documentation for the Java Standard Library).
The turtle graphics implementation we provide in this unit is defined in the Turtle class, and is included in the starter code for this task, available on MyLO. You can read its documentation on MyLO, under Introductory Programming Notes I KIT101 Support Library I AP/ Documentation. The key methods you’ll be interacting with are:
Turtle method Description
penUp() Lifts the virtual pen up. Any movement will not draw a line
penDown() Places the virtual pen down. Any movement will draw a line
turn(double delta) Rotates the turtle delta degrees counter-clockwise
move(double dist) Moves the turtle dist units (pixels) in its current direction
Turtle method Description
origin() Moves the turtle to the bottom-left of the drawing area without drawing a line or modifying whether the pen is up or down
setC010r(C010r c) Changes the pen colour to c. Requires import java . awt . Color; at the top of the program
Tip: Unlike ‘real’ computer graphics, where the origin (0, 0) at the top-right, turtle graphics typically places it at the bottom-left, with increasing values of its y-axis position moving the turtle up.
Work through the following steps to complete the task, which has three parts: modifying an existing program; creating an algorithm for a new program to draw your initials; and then implementing that program.
Part 1: Add some colour
1 . Download the 2.1 PP Turtle Graphics Starter Code from MyLO. Extract the folder 2. IPP Turtle Graphics from the zip file. The unzipped folder should contain RainbowTurt1e. java, Initials . java and a kit101 subfolder.
Tip: Be careful on Windows, which allows you to navigate a zip file as if it were a normal folder. It will even let you ‘open’ the files it contains, except what it actually does it extract just that file to the temporary files directory before DrJava or another suitable program opens it. Since much of the time you’ll need other files for your program to work (the Turtle in this task), this will not work. So, always be sure to extract all the contents to your work area (which should not be Downloads).
2. The first task uses the file RainbowTurtIe.java. Open it in DrJava and read the program.
Activity: Read and understand the code in the program RainbowTurt1e. java
For the lines between the comments, document each method call in a table like the one below. Write your own answer before revealing the solution.
Identifier of object containing How is the return value used? Method name What arguments are passed?
the method (n/a if there is no return value)

Method name Identifier of object containing the method What arguments are passed? How is the return value used? (n/a if there is no return value)

3. Compile and run RainbowTurt1e. java to see what it does. Then close the Turtle Graphics window.
4. See at the top of the RainbowTurt1e . java file that it imports java . awt . Color, but it doesn’t yet actually use it. Modify the program by inserting calls to the turtle’s setC010r() method so that each of the four shapes—square, triangle, rectangle and cross—is a different colour (and no longer the default black).
Tip: The Color class predefines the following colours as class-level data: black, darkGray, gray, lightGray, white, pink, red, orange, yellow, green, cyan, blue. For example, Color. RED is a Color object representing the colour red.
5. Take a screenshot of your running program and save it to submit once you’ve completed the next two parts of the task.
Part 2: Write a high-level algorithm
6. In Word or another document editor of your choice create an algorithm for using a turtle to draw your initials, using the commands
steps of your algorithm. Because this is just an algorithm you do not need to precede each command with an object name. When defining your algorithm keep in mind:
o that the turtle will initially be in the centre (250, 250) of a drawing area, facing east, with its pen down and using black l ink’; and o that in this task you should only use the commands penup, penDown, turn, move and, optionally, setColor (do not use origin in your algorithm or implementation as it will make Task 3.3PP very difficult).
Note: Your drawing does not need to look ‘good’. Letters with curves are really hard to create in turtle graphics, so squarer shapes are fine. Imagine a digital clock display and how a 5 resembles an S.
Tip: Remember to include your name at the top of the document.
Part 3: Implement the algorithm
Stop! Have you written the algorithm for this yet? If not then do that now before you write any code.
8. Open the file Initials.java. You’ll see that it partially implements your algorithm from Part 2. (Well, it declares and creates the Turtle, leaving the rest to you, but that’s still ‘partially.)
9. Translate your algorithm into Java code. Compile and test it as you go. If you find algorithmic mistakes (if it doesn’t draw what you intend) then also update your algorithm from Part 2.
10. Take a screenshot of your running Initials program.
1 1 . Finally, submit the five required files: the two screenshots (of RainbowTurtle and Initials), two completed programs (RainbowTurtle.java and Initials.java) and one algorithm document to the 2.1 PP submission folder on MyLO.

Reviews

There are no reviews yet.

Be the first to review “KIT 101 Programming Fundamentals Solved”

Your email address will not be published. Required fields are marked *