Similarly, if we sold dogs and cats in our pet store, we'd also need to define classes for dogs and cats.
What if you weren't selling pets, but rather had your own boba shop?
What objects are you selling? You would need a class to define that.
Would attributes such as "species" and "lifespan" be appropriate?
Can you think of any attributes that are important when selling boba, but not when selling pets?
This is why we need to know about classes and objects!
EXERCISE 1: Let's say you need to write a program to manage information of students at your school (since they'll all be learning remotely). What would you need to describe a student?
EXERCISE 2: How about the drinks available at your boba shop?
2. So, what is a class?
Class definition: a set of attributes to define any type of object (fish, student, boba drink, etc.) where you declare that everything that you call a fish/student/boba drink must have ALL of those attributes (a fish's species, a student's first and last name, the size of a boba drink, etc.)
3. But, only having classes are not enough. Think about a goldfish and beta fish.
In the real world, you would buy a specific fish and not just "any fish with a color, length, weight, and lifespan". Generally, you wouldn't go to the cash register without knowing that you want a goldfish, beta fish, or something else. The beta fish and goldfish that you see above are objects of type Fish.
Similarly, when you meet a student, you would know immediately that, for example, his name is John, he is in 7th grade, and he takes algebra. You would expect every student to have a name, a grade level, and one or more classes they are taking; there is no such thing as a generic student with no name, grade level, or anything else. John is an example of an object of type Student.
4. How would you apply the concept of classes and objects to the real world?
In the case of your pet shop, you can answer questions such as...
How many beta fish do I have for sale?
How much money have I made selling goldfish?
A customer wants an angelfish that costs no more than $4.99. Can I satisfy their request?
Can you think of other questions related to the day to day operations of a fish shop? What attributes of fish would be needed to answer those questions?
HW: Imagine you are an air traffic controller at San Francisco airport. Can you give 5 attributes for all the flights that take off and land?