Hi There!

I'm Dan Schlegel, an Associate Professor in the Computer Science Department at SUNY Oswego

Assignment 6: The Inflatable Household

In this assignment you will model two classes – balloon people and balloon families, allowing you to practice your class modeling, good programming techniques, and your use of constructs like ArrayLists.

Why do it?

This assignment glues together nearly everything we’ve done this semester, and will provide excellent practice for the final exam!

The BalloonPerson Class

  1. Create a new Java class called BalloonPerson in the balloonpeople package.
  2. Create the instance variables and constructor for BalloonPerson based on the fact that balloon people have a name, an age in years, and a height in inches. Think about what types make sense to use for those. Remember that the purpose of a constructor is to initialize the instance variables.
  3. Add a toString method to your BalloonPerson class which returns a string with the balloon person’s name, age, and height formatted in a nice way.
  4. Remember that classes are developed, not written, so create a Java main class file to test your BalloonPerson class. We’ll be adding some painting mechanisms to the BallonPerson class in a minute, so you might want to use the skeleton at the bottom of this page.
  5. We now wish to paint our balloon people. Add another instance variable to your BalloonPerson class for the color balloon(s) used, and initialize it with a random color at the appropriate point in your code.
  6. Add a method called paint to your BalloonPerson class which takes as an argument an SPainter. In this method, paint your balloon person. Make use of (at least) the defined height. You may use only circles for drawing the person. Use your imagination! Be sure to use good practices as far as problem decomposition and invariance.
  7. Test your BalloonPerson class by enhancing your tests from before. You’ll need to make an SPainter to pass to the BalloonPerson’s paint method. Iterate on your design until you are happy with it.

The BalloonFamily Class

  1. Create a class called BalloonFamily in your balloonpeople package.
  2. Your class should have a single instance variable – an ArrayList of balloon people.
  3. Your constructor will take one argument, the number of people in the balloon family. The goal of your constructor will be to initialize the ArrayList instance variable as a new empty list, and to populate it with balloon people according to user input.
  4. Use the techniques we’ve used before this semester to create popup windows to ask the user for the information required to make the balloon people, and add them to the ArrayList. Be sure you make as many as specified by the argument to the constructor!
  5. Add a toString method which returns a String containing the details of each balloon person in the family. You should make use of the BalloonPerson’s toString method.
  6. As before, create a tester class to make sure your class is working as it should.
  7. Add a method, called paint, to the BallonFamily class. It will take one argument, an SPainter. This method should make calls to the paint method in each of the balloon people stored in the ArrayList. Paint each family member side-by-side.
  8. Test your BalloonFamily class by enhancing your tests from before. You’ll need to make an SPainter to pass to the BalloonFamily’s paint method. If it doesn’t work as you expect, go back and fix it!

The Testing Skeleton

The Exit

  1. The assignment is due May 10th, the last day of classes.
  2. There is no “grace week” or half-credit period for this assignment. It must be demoed on or before May 10th.
  3. Please post your work to you work site.
  4. Reflect on this assignment, your solution, and their relationships with the course content. Think on your engagement with the assignment and the course.