Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
the littlest prince
Sep 23, 2006


American Jello posted:

OK, I know homework questions are frowned upon here, but I just want to make sure I'm on the right track. We are supposed to create a real-world entity, then make a subclass that is a specialized form of that entity. I've got both of those done. (CellPhone and SmartPhone, smart phone having data minutes in addition to regular minutes and all the other stuff cell phone has via super();).

The final part is where I'm getting a little confused. it says 'Illustrate composition by developing a third class that is used by one or both of the first classes[in my case cell/smartphone]'. I'm planning on creating a customer class that 'has-a' cell phone or smart phone. Is this what y'all think he's trying to get us to do? If i create a constructor with a cellphone argument, can I put a smartphone in there?


edit: Okay, I threw the customer class together and I could use either one. I'm pretty sure I'm on the right track, but I'd still greatly appreciate any advice.

If the third class needs to 'be used' by one of the first two, a Customer would 'use' a phone, rather than than a phone 'using' a customer. So you might make a class for a phone number and say that they both 'use' a phone number, or a web browser, which only the smart phone uses. But I doubt that's the important part. I think what you're supposed to understand is the difference between having an instance of a class (customer has a phone), and being an instance of a class (smart phone is a cell phone).

You also might be making this more complex than it really is, because it sounds like you have it down just fine.

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply