CSC148H1 Lecture Notes - Lecture 6: List Comprehension, Init, Object Copying

62 views8 pages
School
Course
Professor
katrinasavvy and 38715 others unlocked
CSC148H1 Full Course Notes
1
CSC148H1 Full Course Notes
Verified Note
1 document

Document Summary

References: the code seen in the pictures can be found on the csc148 website: http://www. teach. cs. toronto. edu/~csc148h/winter/index. shtml. We want to devise the following class. Class square will use other classes -> composition. Composition- 1 class contains instance of another class. First use composition when you need to do extra things: composition defined by has a . Drawing the square using turtle sleep(5: needed to display drawing screen for a longer period of time. We want to draw right angle triangle. A lot of the code used to write class square can be used to draw a right angled triangle. Alter class square into the class shape super class. Put common features into shape and get_area unimplemented as a placeholder. Declare rightangletriangle and square as subclasses of shape class square(shape): Subclasses use 3 approaches to recycle code from their superclass -> usng the same.

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