Computer Science 1026A/B Chapter : Computer Science 1026 Topic 3.docx

55 views3 pages
terubarenuka and 39895 others unlocked
COMPSCI 1026A/B Full Course Notes
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents

Document Summary

To create an object of a class, a special keyword" new" is used: new classname(value,value); By only creating an object, there is no way to refer to it repeatedly. A reference variable is therefore needed: class name, class name = new class(value,value); declaration and referencing done on one command. Creating a world: a world object is an empty canvas with default size of 640 x 480, new world(), world world1 = new world (); creates a world and assigns a reference variable world1 to it. Creating a turtle: a turtle object lives in a world (must be specified), and by default starts facing north and in the center, a turtle will not move out of the boundaries of the world. Turtle turtle1 = new turtle(world1); creates a turtle, and assigns it to world1: turtles can be created at different starting positions.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions