3

On my next step of learning Java, I'm now on Classes and Inheritance.

I have one homework to solve but I'm a little stuck so I'm here not asking for code but to see if you agree with the way I'm thinking and if not, help me with some guidance. Please understand that unfortunately I do not understand all of Java and I'm taking baby steps on this language.

So, here is the problem:

It is intended to create a program that supports the orgazation of conferences. A conference has a name, a location and a date. In addition, each conference has a organization committee and a program committee. Members of both committees are identified by name, email address and institution. The organization committee members are also characterized for their role in the conference (finance, spaces or meals). The program committee members are characterized by a parameter that reflects their performance in the previous edition of the conference (poor, fair, good, excellent). In addition, program committee members are also associated with a list of articles that need review.

Each article is characterized by it's title, list of author's and the evaluation result (note between 1 and 5, with 5 being the best). The final evaluation of each article is obtained by the average of the evaluations conducted by two members of the program committee. The authors are characterized by name, email address, institution and registration fee. This fee can be of two types: senior (teachers or researchers) and students. Students should consider the degree (bachelor, master or doctorate).

The conference registration fee is 400$ for seniors and 200$ for students. A subscription entitles you to submit one article. Senior authors who want to submit more than an article must pay 50$ for each additional article. It is considered that the first author of each article will be responsible for its presentation at the conference.

With this I have to implement some functions but that's not why I'm here.

Reading the problem i can see that

name
email
institution

is used to identify member's of committee and authors.

So I was thinking of creating an

public class Identification{
    ---------------
    name
    email
    institutionName
    ---------------
}

and then everything gets complicated because I know I have to create some that extend that class.

I can create

public class Conference{
    ---------------
    name
    location
    date[]
    ---------------
}

and then

public class Organization extends Conference{
    ---------------
    role[] // 0 for finance, 1 for spaces and 2 for meals
    ---------------
}

and

public class Program extends Conference{
    ---------------
    performance[] //0 poor, 1 fair, 2 good and 3 excellence
    articlesList[] // probably an id of and article
     ---------------
}

but both classes Organization and Program have members and this members are identified by the same thing that is on class Identification. As I now, Java can only extend one and only one class so now I'm stuck how this things relation between themselves.

Reading the rest of the problem I identify

public class Article{
    ---------------
    title
    listOfAuthors[] //probably an id
    evaluation //this is done by two members on program committee but I can't figure out how they relationship between themselves.
     ---------------
}

public class Authors{
    ---------------
    type[][] // 0 for seniors and 1 for students on first column and 0 teachers, 1 researchers, 2 bachelor, 3 master and 4 doctorate on second column.
    numberOfArticles //how many articles author wants to submit
    conferenceFee[] // if on type[i][0] is 0 then Fee is 400 + (numberOfArticles * 50)  else is 200
    ---------------
}

Is this the way or not. I can't understand if I have to create all of this classes and what class extends the other class. Any comment?

favolas

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thanks for all your feedback. Let's see if I understood at least some of your suggestions.

public class Member{
    ---------------
    memberID
    name
    email
    institutionName
    ---------------
}

public class Authors extends Member{
    ---------------
    authorsID
    conferenceFee
    ---------------
}

public class Seniors extend Authors{
    ---------------
    degree[] // 0 for teachers 1 for researchers
    numberOfArticles = // Some int
    fee = 400

    public int payment(int numberOfArticles ){
        return numberOfArticles * fee;
    }
    ---------------
}

public class Students extend Authors{
    ---------------
    degree[] // 0 bachelor, 1 master and 2 doctorate
    numberOfArticles = // Some int
    fee = 200

    public int payment(){
        return fee;
    }
    ---------------
}

public class Article extend Authors{
    ---------------
    articleID
    title
    listOfAuthors[] //probably an id
    ---------------
}

public class ProgramCommitteeMember extends Member{
    ---------------
    role[] // 0 for finance, 1 for spaces and 2 for meals

    ---------------
}

public class OrganizationCommitteeMember extends Member{
    ---------------
   lasYearPerformance[] //0 poor, 1 fair, 2 good and 3 excellence
   articlesList[] // probably an id of and article
    ---------------
}

public class Committee{
    ---------------
    committeeType[] // 0 for Organization Committee and 1 for Program Committee
    ---------------
}

public class OrganizationCommittee extends Committee{
    ---------------
    listOfMembers[] //member id
    ---------------
}

public class ProgramCommittee extends Committee{
    ---------------
    listOfMembers[] //member id
    ---------------
}

His this the way?

5 Answers 5

2

I think you're confusing inheritance and composition.

Is an Organization a kind of Conference? If not, don't inherit from it. One of them needs to contain the other - when the first one goes away, the second must. It may be also be true that the other one needs to refer back to the first - that the child needs to know their parent. That's ok too.

Is a Program a kind of Conference? Same thing goes here, too.

Take a look at the Liskov Substitution Principle.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Conference as two committees. One is Organization committee (hence class Organization) and the other is Program Committee (hence class Program).
0

I see several points where I think you've gone off the rails.

  1. You show date as an array in Conference. Each instance of Conference has only a single date.

  2. You show both Organization and Program as a subclass of Conference. They should not be. Instead there should be a superclass called Committee, with two subclasses, OrganizationCommittee and ProgramCommittee. Then your Conference class has two internal variables, one each of type OrganizationCommittee and ProgramCommittee. In other words, a "committee" is not a type of a "conference," it is a member of a "conference." (By member here, I don't mean "a person going to a conference," I mean, "an object that is owned by another object.")

  3. Each committee has members. So you need a Member superclass, with two subclasses, OrganizationCommitteeMember and ProgramCommitteeMember. Your ProgramCommittee will then contain a list (an array for exmaple) of ProgramCommitteeMembers, and your OrganizationCommittee will contain a list of OrganizationCommitteeMembers.

  4. One other thing, you show role[] as an array in Organization. First, a role applies to a member of a committee, not an organization. Second, each member has only one role. What you need is a way to define a prescribed list of roles, so that only one of several valid values can be assigned. But each member has only a single role.

Key on where your instructions use the phrase "has a" (which implies that one class contains an instance of another class) versus "is a" (which implies that one class is a type of a parent class).

Hope this helps to get you on the right track.

1 Comment

Thanks dnuttle. 1 - My bad. Date is an array because index 0 will have year, 1 month and 2 day. 2 - Thanks. I understood that. 3 - In the beginning I've thought doing that but somewhere along the road I've dropped the member superclass. 4 - Ok. That role should be an variable in OrganizationCommitteMember
0

Have a close look at the "entities" you need to represent. Entites will probably become objects in your program. What entities/objects do you need? - Start, for instance, with the entities "commitee" and "committee member".

Once you found all your involved entities, you can start to look at and compare them:

Are there different entities which have things (properties) in common? These are candidates for a common super-class of those entities. Your proposed Identification class is just the right way to do it. Now take it a step further: Which entities share the property of being "identifiable"? Those should inherit from Identification.

Also remember that "class B inherits from class A" usually means "B is a special kind of A". Is your organization a special kind of conference?

1 Comment

Thanks Hanno. I identified that authors, organization committee member and program committee member all have identification in common so I thought that Identification should be they're parent class but a conference as an organization committee and an program committee so I also thought that they are children of conference so something is wrong
0

You're correct that Java does not allow multiple inheritance (that is, each class can only extend one other class).

In general, the idea with classes, subclasses and inheritance is that objects of particular subclasses are specific kinds of their super class. For example, it would make sense to have a class Animal, and then create a subclass Horse that extends Animal.

Or, using the framework you've introduced, you could have an Author class, and then a Senior class and a Student class, both of which would extend Author. A nice way to take advantage of this structure could be to include a pay() method in each of the three classes that returns an int. Since student authors only need to pay $200, the pay() method in the Student class would return 200 while the pay() method in the Senior class would return 400. The key observation here is that now you can call the pay() method on any object that is an Author, so you don't need to check in advance whether the author is a senior or a student. You should be able to think of similar ways to handle the other areas of the problem.

1 Comment

Thanks. Initially I've thought making those classes but made a mistake of thinking they where two many.
0

Not much inheritance in there, I think I'd be using aggregation and interfaces all the way through.

Member (you called this identification) Then CommitteeMember extends Member and ProgramCommitteeMember extends Member

Look at inheritance as X is a Y

Organisation is a Conference doesn't really make sense. It's the role a committemeber fulfilled at a conference. so Conference and Conferences then Role describes member and conference.

Program committee member hasa performance against a conferences so again you have Conference, Conferences and Performance describes memebr and conference.

So you could define a base class conferencemember and then extend that for role and performance.

It's all about has a and is a A book has an author. An author is a writer.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.