java - How to connect two different classes -
i properties of customer
class booking
class without using extend because customer
property of booking
, not extension. how in best way?
public class booking implements serializable{ private string flighttime; private string flightlocation; private string flightfee; private boolean car; private boolean insurance; private customer customer; ... } public class customer extends person implements serializable { private string passportid; private string consultantname; private string consultantsurname; private string consulid; .... } private void savebookingbuttonactionperformed(java.awt.event.actionevent evt) { booking customerbooking = new booking(); try { if (custnametf.gettext().equals("")) { throw new emptyfield("please insert customer"); } else { fileoutputstream fos = new fileoutputstream( "bookings/" + custidtf.gettext() + ".txt"); objectoutputstream oos = new objectoutputstream(fos); customerbooking.setpersonname((custnametf.gettext())); customerbooking.setpersonsurname((custsurnametf.gettext())); customerbooking.setpersonid((custidtf.gettext())); customerbooking.setconsultantname(consnametf.gettext()); customerbooking.setconsultantsurname((conssurnametf.gettext())); customerbooking.setconsulid(considtf.gettext()); customerbooking.setflightlocation(locationcb.getselecteditem().tostring()); customerbooking.setflighttime(timecb.getselecteditem().tostring()); customerbooking.setflightfee(feecb.getselecteditem().tostring()); customerbooking.setcar(carrb.isselected()); customerbooking.setinsurance(insurancerb.isselected()); } } }
you did having customer property.
to or set properties of customer using booking class instance, have write
bookinginstance.getcustomer.setsomething(.... bookinginstance.getcustomer.getsomething(....
Comments
Post a Comment