Jump to content

Sharif11

Member
  • Posts

    2
  • Joined

  • Last visited

Awards

This user doesn't have any awards

Sharif11's Achievements

  1. Sorry I've taken so long to reply. Thank you very much for your help, it was very helpful :)
  2. I,ve been practising java because I want to get good at it. I've been following a book and there's an exercise I'm stuck on. How do I print a summary of the details (instance variables) as well as the current sale outcome for the current PropertySale to the screen? Here's what I got so far: public class PropertySale { private String salesID; private String propertyAddress; private int reservePrice; private int currentOffer; private boolean saleStatus; public PropertySale(String salesID, String propertyAddress, int reservePrice) { this.salesID = salesID; this.propertyAddress = propertyAddress; this.reservePrice = reservePrice; this.currentOffer = 0; this.saleStatus = true; } public String getsalesID() { return salesID; } public String getpropertyAddress() { return propertyAddress; } public int getcurrentOffer() { return currentOffer; } public boolean getsaleStatus() { return saleStatus; } public boolean reserveMet() { if (currentOffer >= reservePrice) { return true; } else { return false; } } public int getReservePrice() { return reservePrice; } public void printSaleDetials() { System.out.println("Sale id is: " + getsalesID()); System.out.println("Property address: " + getpropertyAddress()); System.out.println("Reserve Price: " + getReservePrice()); System.out.println("Current Offer: " + getcurrentOffer()); System.out.println("Sale Status: " + getsaleStatus()); System.out.println(); System.out.println(); } public String getSaleOutcome(boolean saleOpen, boolean saleStatus) { String returnValue = ""; if (saleOpen == true) { returnValue = "ON SALE"; } else { if (saleStatus == false) { returnValue = "SOLD"; } } return returnValue; } public void setCurrentOffer(int offer) { currentOffer = offer; } public void setSaleStatus(boolean status) { saleStatus = status; } public boolean makeOffer(int offerPrice) { if (currentOffer >= offerPrice) { return false; } else { currentOffer = offerPrice; if (reserveMet()) { // print if true // close sale } else { // print if false } return true; } } public void getSaleOutcome() { System.out.println(salesID); System.out.println(propertyAddress); System.out.println(reservePrice); System.out.println(currentOffer); System.out.println(saleStatus); } } The last part is where I'm stuck. I know I'm wrong thats why I wanted some help. It wants me to call a getSaleOutcome method which made me confused. Whats the best way to go about it? Any help is Appreciated:) Thanks
×