Day 7.2 Exercise 42 Is-A, Has-A, Objects, and Classes

Here’s my work.
Here’s the link to exercise 42.

Ex42a Code
Ex42a Code
Ex42a Code 2
Ex42a Code 2
Ex42 Output
Ex42a Output

Study Drill

1. Research why ruby added this strange object class, and what does that means.
…. Object is object, class is class. I’m not sure why? Sounded like why is there addition in math?

2. Is it possible to use a class like it’s an object?
Yes, classes are just like objects.

3. Fill out the animals, fish, and people in this exercise with functions that make them do things. See what happens when functions are in a “base class” like Animal versus in say Dog.
Done. I did not post the pictures here, you may go to my github to check it out.

4. Find other people’s code and work out all the is-a and has-a relationships.

5.Make some new relationships that are arrays and hashes so you can also have “has-many” relationships.
Done. I’ve added hobbies and preferences to person class.

6. Do you think there’s such thng as an “is-many” relationship? Read about “multiple inheritance,” then avoid it if you can.
You just hinted there is such a thing. I’m assuming it could have some contradicting functions.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s