COMP 202 Lecture Notes - Lecture 24: Mutator Method

44 views8 pages
hwpark22 and 40159 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

Write a class to describe a cat object. Create a class, name it cat, define attributes. The attributes are not static , because the name of the cat is a property of a particular cat instance, not a property of all cats. So far, all of our attributes and methods that we have written have been public . A public method or attribute can be accessed from outside of the class file in which it was written. In contrast, an attribute or method with a private modified cannot be accessed from outside the class file in which it was written. By making an attribute or method private, you are creating rules about how other people can access your code. For example, maybe you would like to allow someone to access a value, but not change it! s. length(); < you can access the length of a string, but you cannot change it manually.

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