Im having a few problems creating basic classes and was wondering if you could give me some ideas, basically i need...
Room class
+Data
name of room
can contain up to 10 animal objects // use an Array of objects? how to declare
+Constructor
room name
+public void addAnimal(Animal a) method //add animals into the array
+toString() that calls Animals toString() //returns name of room as well as the names of animals inside the room
and an...
Animal Class
+Data
name of animal
+Constructor
intitalize animal name
+room reference // Animal objects need to know what Room they are in
+toString() - returns names of all animals in the room
so far i have ...
public class Room {
// instance variables
String name;
// constructor
Room(String name) {
this.name = name;
}
// array that limits the amount of animals in a Room object
roomArray = new String[9]
// methods
}
public class Animal {
String name;
Animal(String name){
this.name = name;
}
}

New Topic/Question
Reply




MultiQuote





|