I have a ArrayList of objects which stored either a ForSaleProperty object or RentalProperty object;
static ArrayList<Object> obj = new ArrayList<Object>();
My RentalProperty and a ForSaleProperty is subclass of Property
RentalProperty extends Property
ForSaleProperty extends Property
Inside Property, I have an Address and ViewingArrangement object.
In ViewingArrangement, i have a ContactPerson object an a String openTime variable. I also have the method setOpenTime in ViewingArrangement.
Problem :
How do i access the setOpenTime() method in ViewingArrangement.
In my Object arraylist, i have this
RentalProperty rp1 = new RentalProperty(1500,"6-Jun-16");
Address a1 = new Address(150,"Tampines Ave 5","Singapore",6002);
ContactPerson cp1 = new ContactPerson("Benjamin","Murdoch",2738482);
ViewingArrangement va1 = new ViewingArrangement(cp1,"1000H");
rp1.setAddress(a1);
rp1.setVA(va1);
obj.add(rp1);
So now i want to change the openTime of rp1.
I tried the following but cant access the method in my object.
static void editOpenTime()
{
int input;
String newOpenTime;
listProperty();
Scanner in = new Scanner(System.in);
System.out.println("Enter property number : ");
input = in.nextInt(); in.nextLine();
System.out.println("Enter new open time for property # : "+input);
newOpenTime = in.nextLine();
obj.get(input).
}