On Mon, 21 Apr 2008 07:58:23 +0000, thufir wrote:
> I've looked around, but haven't found the information I was looking for
> yet. Strictly looking at the syntax for assigning a row of ADDRESS_DATA
> to the address object, is there a more compact syntax?
[...]
> //creates new instances of each Guest attribute //It might be
> better to treat name, contactInfo and address //as mutatable.
> Not a major point.
> public Guest newGuest(int row){
Aha, now it works:
/*creates a new instance of guest from GUEST_DATA and
ADDRESS_DATA for a given row (guest id number?)
this method is more complex than it should be
but accomplishes the requirement of:
Write a separate class that creates three guests from a data
array.
folding Name, Address and ContactInfo into one class
would simplify Lab2 enormously. */
public Guest newGuest(int row){
name = new Name(GUEST_DATA[row]);
contactInfo = new ContactInfo(GUEST_DATA[row]); //
totally redundant
address = new Address(ADDRESS_DATA[row]);
Guest guest = new Guest(name,contactInfo,address);
return guest;
}
I swear that I'd tried to pass a row before and it didn't work, but,
anyhow, now it does :)


|