Title | Tutorial 1-Introduction to Java Turtle Graphics |
---|---|
Author | 美君 刘 |
Course | Programming |
Institution | Universiti Kebangsaan Malaysia |
Pages | 3 |
File Size | 241.5 KB |
File Type | |
Total Downloads | 73 |
Total Views | 138 |
Turtle Graphic...
TK1114 COMPUTER PROGRAMMING
Tutorial 1 Introduction to Java & Turtle Graphics Section A: Sign up to OpenLearning Sign up to our MOOC Java content at OpenLearning.com here: https://www.openlearning.com/courses/programming-in-java/HomePage Access code: tk1114ftsm Note: Please use your @siswa.ukm.my email Once you’re in, do introduce yourself at the “Get to Know Me” tab.
Section B: B: Introduction Introduction to Java 1. In OpenLearning, browse to Learning Activities -> Topic 1 : Introduction to Java Programming & Turtle Graphics -> 1.1 What do I need to know about JAVA Watch the video, and discuss what you have learn from the video.
Section C: C: Objects: Objects: Using, Using, creating creating and and communicating communicating 1. You are given the Turtle Graphics Documentation at the end of this document and the following MyTurtleApp.java program. Trace the program to understand how Turtle Graphics works. What is the output of the program?
1
Sem1 2018/2019 session
TK1114 COMPUTER PROGRAMMING 2.
Trace the following MyTurtleApp2.java program. What is the output?
3.
Sketch a triangle. By using the appropriate methods in Turtle Graphics Documentation, write a program to draw the triangle.
4.
Write the statements to draw letter ‘E’
2
Sem1 2018/2019 session
TK1114 COMPUTER PROGRAMMING
Turtle Graphics Documentation
MWorld class
MWorld() Creates a new MWorld for MTurtles to play in. MWorld size is 640 x 480 MWorld(String title) Creates a new MWorld frame with title MWorld size is 640 x 480 MWorld(String title, int width, int height) Creates a new MWorld frame with title MWorld size is width x height
MTurtle class MTurtle(MWorld w) Makes a new turtle in the center of the world.
void forward(int distance) Moves the turtle forward by the distance. void turnRight(double degrees) Turns the turtle clockwise in place. void penDown() Causes the turtle to leave a trail. void penUp() Stops the turtle from leaving a trail. void setPenWidth(int newPenWidth) Sets the width of the line void setPenColor(Color color) Changes the pen color to a new color void setColor(Color color) Changes the current turtle color void moveTo(int x, int y) changes the turtle's location to (x, y)
3
Sem1 2018/2019 session...