Today, the ANNUALLEASE class is completed, and the association between Boat and Customer is completed, and two methods are added in BOAT.
1.public void assignboattocustom (Customer ACUSTOMER) // vessel and customer association
{
SetCustomer (Customer ACUSTOMER); // CONECT 1 .... 1
Customer.SetBoat (this);
}
2.Public void assignboattoattoslip (aslip) // vessels and hull
{
Setslip (aslip);
Slip.setBoat (this);
}
Also adding the test method of the BOAT class is used to test the implementation of each method in SLIP and Boat:
3.Public string tellaboutself ()
{
// boat information
String botdetails = "i am a boat"
"State Reg Number" GetStateRegistrationno ()
"Length" getLength ()
"Manufacturer" getManufacturer ()
"Year" getYear ();
String CustomerDetails = "/ n And Owner IS"
Customer.getname ()
"Living in" Customer.Getaddress ()
"with phone Customer.getphoneNo ();
Return Boatdetails CustomerDetails;
}
// not tested entire Boat.java Code: package com.tianyu.summer; public class Boat {private String stateRegistrationNo; private double length; private String manufacturer; private int year; private Customer customer; private Slip slip; public Boat (String aStateRegistrationNo, double aLength, String aManufacturer, int aYear, Customer aCustomer) {setStateRegistrationNo (aStateRegistrationNo); setLength (aLength); setManufacturer (aManufacturer); setYear (aYear); assignBoatToCustomer (aCustomer); setSlip (null);} public void assignBoatToCustomer ( Customer aCustomer) {setCustomer (aCustomer); customer.setBoat (this);} public void assignBoatToSlip (Slip aSlip) {setSlip (aSlip); slip.setBoat (this);} public String tellAboutSelf () {// Boat information String boatDetails = "I am a boat" "state reg number" getStateRegistrationno () "length" getLength () "manufacturer" getManufacturer () "year" getYear (); string customerdetails = "/ n And Owner IS " Customer.getName () " Living in " Custo mer.getAddress () "with Phone" customer.getPhoneNo (); return boatDetails customerDetails;} public void setStateRegistrationNo (String aStateRegistrationNo) {stateRegistrationNo = aStateRegistrationNo;} public void setLength (double aLength) {length = aLength;} public void setManufacturer (String aManufacturer) {manufacturer = aManufacturer;} public void setYear (int aYear) {year = aYear;} public void setCustomer (Customer aCustomer) {customer = aCustomer;} public void setSlip (Slip aSlip) {slip = aSlip; } Public string getStateRegistrationno () {Return STATEREGISTRATIONNO;
} Public double getLength () {return length;} public String getManufacturer () {return manufacturer;} public int getYear () {return year;} public Customer getCustomer () {return customer;} public Slip getSlip () {return slip; }} // Complete the association of Lease, the principle, the above class, the code of the class is: package com.tianyu.summer; import java.util. *; Public abstract class lease {private Double Amount; Private Date StartDate; private date enddate ; private Customer customer; private Slip slip; public Lease (Date aStartDate) {setStartDate (aStartDate); setEndDate (null); setAmount (0); setCustomer (null); setSlip (null);} public abstract double caculateFee (int aLength) ; public void setAmount (double anAmount) {amount = anAmount;} public void setStartDate (Date aStartDate) {startDate = aStartDate;} public void setEndDate (Date anEndDate) {endDate = anEndDate;} public void setCustomer (Customer aCustomer) {customer = Acustomer;} public void setslip (slip aslip) {slip = aslip;} public double getamount () {return amount;} public date getStartDate () {Return Star PUBLIC CUSTOTOTDATE;} public slip;}}} public slip;