CIS 110 Spring 2013 - Introduction to Computer Programming

upenn.edu | directories | van pelt library
seas.upenn.edu | CETS | engineering library
computer graphics & game dev (SIGGRAPH @ Penn) | dining philosophers (DP) | science & tech wing (STWING) | women in cs (WICS)
CETS Answers

Recitation 7 Exercises

Goals

The goals of this week's recitation assignments are to learn how Objects are structured and created and what the small differences between Objects and programs we've written so far are.

Exercises

  • What is the difference between a static and non-static variable?
  • Come up with an idea for an object that has three attributes (adjectives/nouns), and three actions (verbs). You can write this as a Java class, or just an English description (that you will convert to Java during recitation). For example, an elephant has a weight, trunk length, and playfulness. It can honk, spray water, and stampede. Ultimately, the attributes will become instance variables, and the actions will become methods in your Java class.
  • Come up with a second object that uses your first one. This should also have three attributes/parts and three actions. For example, a circus uses elephants. One of the instance variables in a circus class might be an array of elephants.