Member Avatar for 9w43

I have 2 classes inside bluej, member class and trip class so when I make a member object with student ID, name and course, how can I make an ArrayList or HashSet on trip class which needs to store those students. If you have used bluej you know what I am talking about.
here is my trip class code:

import java.util.*;
/**
* Write a description of class Trip here.
* 
* @author (your name) 
* @version (a version number or a date)
*/
public class Trip
{
//fields
private String code;
private String pName;
private String venue;
private Date tDate;
private double cost;
private int mMember;
private int aPoints;

/*
* Constructor for Trip Class
* Task 1.1
*/
public Trip(String codeC, String pNameC, String venueC, double costC, int mMemberC, int aPointsC)
{
code = codeC;
pName = pNameC;
venue = venueC;
cost = costC;
mMember = mMemberC;
aPoints = aPointsC;
allStudents = new ArrayList<Member>();

}

/*
* Mutator for setting date
* if Date has already been created just type object name eg date1
* the date from date1 will be copied to Trip date
* Task 1.2
*/
public void setDate(Date enterDate)
{
tDate = enterDate;
}

/*
* Accessor for Trip code
* Returns Trip code
* Task 1.3
*/
public String getTripCode()
{
return code;
}

/*
* Accessor for title (pName)
* Returns performance title
* Task 1.3
*/
public String getTitle()
{
return pName;
}

/*
* Accessor for cost
* Return title cost in double
* Task 1.3
*/
public double getCost()
{
return cost;
}

/*
* Accessor for date
* Returns Date
* Task 1.3
*/
public Date getDate()
{
return tDate;
}

/*
* Method for returning trip details as String
* Task 1.4
*/
public String getTripDetails()
{
return ("Trip code is " + code + " Trip title is " + pName + " The venue is at " + venue + " It is held on " + tDate + " Ticket cost is " + cost + " Maximum members allowed is " + mMember + " Attendance points are " + mMember);
}

}

Recommended Answers

All 2 Replies

BlueJ is just a tool and doesn't provide different/unusual/strange/special Java code, so no point mentioning it.
As for HashSet you can read this tutorial

Member Avatar for 9w43

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.