class relationship problem

i am current stuck on a project i am developing for my university course.

i have make a simple holiday booking class which i have done

view here http://www.geocities.com/tyront01/holidayRecord.txt

the problem is i have to now make a second class that will take all this information into a collection this is what i've got so far

http://www.geocities.com/tyront01/holidayPlanner.txt (not much)

I bileve i've got to put this information into a arraylist but after 6 hours i have not found a way to successfully do this.

as the deadline is rapidly approching any info would be increadably helpful

thanks in advance

tyront

[677 byte] By [tyronta] at [2007-10-1 0:45:49]
# 1
I can't be bothered to go download your code. OK, not can't, but won't. But if you ask a more specific question I'd be happy to help. Have you read the Collection API docs? Do you know how to create an ArrayList? Do you know how to add things to it? Where exactly is the struggle?
nasch_a at 2007-7-8 0:59:24 > top of Java-index,Security,Event Handling...
# 2

i have read the api and my java book big java but they provide me with little help for what i thought would be something quite easy

basicly i have made a holiday record with the attributes employee id, allowence and count. allowence is for how many days that they are allowed and count is for how many days they have left. i have also made all the methods needed for that part of this

the problem is i need to make some sort of collection which can store the holiday records in one attribute of holidayPlanner which is the class i am working on now. can't seem to find a way of getting the classes attributes in a arraylist (most proberble collection)

any help would be greatly apreiatied

kind regards

tyront

tyronta at 2007-7-8 0:59:24 > top of Java-index,Security,Event Handling...
# 3

> can't seem to find a way of getting the classes

> attributes in a arraylist (most proberble

> collection)

There are three steps: 1) declare collection 2) instantiate collection (make a new one) 3) put things in collection. Which part are you having trouble with, and what's the code for that part that you have so far? What are your error messages?

nasch_a at 2007-7-8 0:59:24 > top of Java-index,Security,Event Handling...
# 4

I have a doubt. Your holidayPlanner class extends holidayRecord. My doubt is that holidayPlanner IS-A holidayRecord. More likely, holidayPlanner is composed of holidayRecords. Therefore, use composition rather than inheritance.

I really don't understand holidayRecord - you need more comments in there so the reader can understand what's going on. IRL, I'm an employee with certain leave entitlements and I understand my employer's leave records - but I don't understand your classes.

Coding conventions - your classes should start with a capital letter; HolidayRecord and HolidayPlanner - not holidayRecord and holidayPlanner. Spell allowance correctly. What is variable "count" - a count of leave taken or yet to be taken? Use meaningful names for variables.

Back to your question - use composition as I stated earlier, so...

class HolidayPlanner {

// instance variables

private String companyID;

private String year;

private ArrayList holidayRecords;

You could, however, use collections other than ArrayList.

EdenMonaroa at 2007-7-8 0:59:24 > top of Java-index,Security,Event Handling...
# 5
yes that was the answer thanks alot for all help provided kind regards tyront
tyronta at 2007-7-8 0:59:24 > top of Java-index,Security,Event Handling...