hi.
My problem is that I create a number of instances, they all have completely valid methods to assign instance to instance.
When I call these methods in one long method, it works, and all the instances become related etc, but when I call seperate methods from main, each to do some part of the assignmnt, it throws up methods about not being able to resolve symbol (can't assign the instances to each other).
----------------------HotelDemo.java-----------------------
public class HotelDemo
{
public void runIt()
{
//public void createAddresses()
//{
Address a1 = new Address();
Address a2 = new Address();
Address a3 = new Address();
Address a4 = new Address();
Address a5 = new Address();
a5.setHouseNo(101);
a5.setRoadName("Oxford Street"
;
a5.setTown("London"
;
a5.setPostCode("W1 3EB"
;
Address a6 = new Address();
a1.setHouseNo(999);
a1.setRoadName("Hope Street"
;
a1.setTown("Aberystwyth"
;
a1.setPostCode("CR55 6TG"
;
//}
//public void createPeople()
//{
Person p1 = new Person("Joe Wardell"
;
p1.setAge(18);
a1.setHouseNo(666);
a1.setRoadName("Sunset Blvd"
;
a1.setTown("New York"
;
a1.setPostCode("RH19 2EB"
;
p1.setAddress(a1);
Person p2 = new Person("Ben Price"
;
p2.setAge(10);
a2.setHouseNo(7);
a2.setRoadName("Smellville"
;
a2.setTown("New Dork"
;
a2.setPostCode("TN22 3NW"
;
p2.setAddress(a2);
Person p3 = new Person("Swanny"
;
p3.setAge(25);
a3.setHouseNo(321);
a3.setRoadName("Side-burnsville"
;
a3.setTown("Bananaramaland"
;
a3.setPostCode("SY67 1NH"
;
p3.setAddress(a3);
Person p4 = new Person("Abi Starling"
;
p4.setAge(17);
a4.setHouseNo(26);
a4.setRoadName("Church Lane"
;
a4.setTown("East Grinstead"
;
a4.setPostCode("RH19 4EB"
;
p4.setAddress(a4);
//}
//public void createHotels()
//{
Hotel h1 = new Hotel("Hilton"
;
h1.setManager(p1);
h1.setReceptionist(p2);
h1.setLocation(a5);
Hotel h2 = new Hotel("Bel-Air view"
;
h2.setManager(p3);
h2.setReceptionist(p4);
h2.setLocation(a6);
//}
}
public static void main(String[] args)
{
HotelDemo hd1 = new HotelDemo();
hd1.runIt();
//hd1.createAddresses();
//hd1.createHotels();
//hd1.createPeople();
}
}
---------------------------------------------------------
If anyone can explain to me why this happens, then I'd be very grateful! we are all of us living in the gutter.
But some of us are looking at the stars.
My problem is that I create a number of instances, they all have completely valid methods to assign instance to instance.
When I call these methods in one long method, it works, and all the instances become related etc, but when I call seperate methods from main, each to do some part of the assignmnt, it throws up methods about not being able to resolve symbol (can't assign the instances to each other).
----------------------HotelDemo.java-----------------------
public class HotelDemo
{
public void runIt()
{
//public void createAddresses()
//{
Address a1 = new Address();
Address a2 = new Address();
Address a3 = new Address();
Address a4 = new Address();
Address a5 = new Address();
a5.setHouseNo(101);
a5.setRoadName("Oxford Street"
a5.setTown("London"
a5.setPostCode("W1 3EB"
Address a6 = new Address();
a1.setHouseNo(999);
a1.setRoadName("Hope Street"
a1.setTown("Aberystwyth"
a1.setPostCode("CR55 6TG"
//}
//public void createPeople()
//{
Person p1 = new Person("Joe Wardell"
p1.setAge(18);
a1.setHouseNo(666);
a1.setRoadName("Sunset Blvd"
a1.setTown("New York"
a1.setPostCode("RH19 2EB"
p1.setAddress(a1);
Person p2 = new Person("Ben Price"
p2.setAge(10);
a2.setHouseNo(7);
a2.setRoadName("Smellville"
a2.setTown("New Dork"
a2.setPostCode("TN22 3NW"
p2.setAddress(a2);
Person p3 = new Person("Swanny"
p3.setAge(25);
a3.setHouseNo(321);
a3.setRoadName("Side-burnsville"
a3.setTown("Bananaramaland"
a3.setPostCode("SY67 1NH"
p3.setAddress(a3);
Person p4 = new Person("Abi Starling"
p4.setAge(17);
a4.setHouseNo(26);
a4.setRoadName("Church Lane"
a4.setTown("East Grinstead"
a4.setPostCode("RH19 4EB"
p4.setAddress(a4);
//}
//public void createHotels()
//{
Hotel h1 = new Hotel("Hilton"
h1.setManager(p1);
h1.setReceptionist(p2);
h1.setLocation(a5);
Hotel h2 = new Hotel("Bel-Air view"
h2.setManager(p3);
h2.setReceptionist(p4);
h2.setLocation(a6);
//}
}
public static void main(String[] args)
{
HotelDemo hd1 = new HotelDemo();
hd1.runIt();
//hd1.createAddresses();
//hd1.createHotels();
//hd1.createPeople();
}
}
---------------------------------------------------------
If anyone can explain to me why this happens, then I'd be very grateful! we are all of us living in the gutter.
But some of us are looking at the stars.