File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Inheritance Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Inheritance Problem" Watch "Inheritance Problem" New topic

Inheritance Problem

cor rupt

Joined: Aug 01, 2012
Posts: 1
Hi, I'm new here. I have a little problem with inheritance. Here are my codes that i made:

The program produces few errors. Please help me with it. Thanks!!!

Naishadh Parmar
Ranch Hand

Joined: Jun 02, 2011
Posts: 95

Can you post the exception stack trace???
Winston Gutkowski

Joined: Mar 17, 2011
Posts: 8946

cor rupt wrote:Hi, I'm new here. I have a little problem with inheritance. Here are my codes that i made:

I suspect others will have dealt with the mechanics, so I'm going to concentrate on what inheritance is.

I have to admit to being intrigued with your idea of making a SilverMember a subclass - for about 30 seconds.

I understand what you're thinking about, but the fact is: It won't wash.
If a Gymnasium is a class that is trying to encapsulate a gym, then SilverMember cannot be a subclass, because it isn't a gym; it's a member of (or possibly a set of rules concerning) a gym.

Create a class called GymMember, and then you may have a case for creating a SilverMember subclass.


Bats fly at night, 'cause they aren't we. And if we tried, we'd hit a tree -- Ogden Nash (or should've been).
Articles by Winston can be found here
LQ McDonald III

Joined: Aug 01, 2012
Posts: 10

Winston has the start of it. Until you fix the super/sub class structure you currently have it doesn't even make sense to diagnose the problem.
I agree. Here's the link:
subject: Inheritance Problem
It's not a secret anymore!