CSE 8A Lecture Notes - Lecture 4: Function Overloading

38 views1 pages

Document Summary

Lecture notes: this refers to object that calls the method: is very general, replaced by object that calls it. Giving method parameters: declare parameter when creating method public void drawsquare (int width) , when you call the method, you input an argument into the () turtle. drawsquare(50); The 50 becomes the value for the width variable. Therefore, the variable"s name can now be used later on in the method"s body: this. forward(width), methods with parameters are different, even though they have the same name. Called method overloading: make methods more general, specify the information you put into methods. Writing methods: avoids copy and pasting code, avoids fixing bugs in more than one place, makes it easier to read.

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