Objects 1


examples


Classwork

1. Create a class representing a volcano, with instance variables for height, and years since last eruption. Give it a behavior erupt that adds 10 to its height, resets years since last eruption, and prints a message describing what happened. In a main, create two volcanos with different values, then have each one erupt

2. Create a class representing a goose, with instance variables for weight and whether it is angry. Give it a behavior honk, that prints honk if it is not angry and HONK if it is. Give it a method eat that increases its weight by 1 and makes it not angry. In a main, create a goose, make it angry, then have it honk then eat, then honk.