setPartnerGendergender getPartnerDescriptionsetMinIncomeminIncome

setPartnerGendergender...

This preview shows page 34 - 39 out of 39 pages.

getPartnerDescription().setPartnerGender(gender); getPartnerDescription().setMinIncome(minIncome); getPartnerDescription().setMaxIncome(maxIncome); getPartnerDescription().setMinAge(minAge); getPartnerDescription().setMaxAge(maxAge); } // print the advertiser's details public void print() { System.out.format("%5d%10s%10s%7s%5d%10d%20s%7s%5d%5d%10d%10d", this.getCustId(), this.getCustName(), this.getCustPwd(),this.getCustGender(), this.getCustAge(),this.getCustIncome(),this.getTextAd(), this.getPartnerDescription().getpGender(),this.getPartnerDescription().getMinAge(),this.getPartnerDescription( ).getMaxAge(), this.getPartnerDescription().getMinIncome(),this.getPartnerDescription().getMaxIncome()); System.out.println(); } // add a new message public void addMessage(String owner,String text,int phone,String email) { int id = mList.size()+1; // increase the size of the message list by 1 ReplyMessage r = new ReplyMessage(id, owner, text, phone, email); // create a new message mList.add(r); //add the message into the list } // delete a message public boolean deleteMessage(int del) {
Image of page 34
boolean deleted = false; // set bool 'deleted' is equal to false // loop through the message list for(int i=0; i<mList.size(); i++) { // if the messageId is equal to input 'del' if(mList.get(i).getMesgID() == del) { mList.remove(i); // delete the message deleted = true; } } return deleted; } // print the content of a message public void printMessage() { //loop through the message list for all the messages stored for(int i=0;i<mList.size();i++) { System.out.format("%5d%10s%20s%10d%20s", mList.get(i).getMesgID(), mList.get(i).getOwner(), mList.get(i).getText(), mList.get(i).getOwnerPhone(), mList.get(i).getOwnerEmail()); System.out.println(); } } }
Image of page 35
ReplyMessage.java package assignment1; public class ReplyMessage { private int mID; // message ID private String owner; // name of the message owner private String text; // details of message private int ownerPhone; // phone number of the message's owner private String ownerEmail; // email address of the message's owner // default constructor public ReplyMessage(){} // constructor with para public ReplyMessage(int id, String owner, String text, int phone, String email) { this.mID = id; this.owner = owner; this.text = text; this.ownerPhone = phone; this.ownerEmail = email; } // create a new message public void createReplyMessage(int id, String owner, String text, int phone, String email) { this.setMesgID(id); this.setOwner(owner); this.setText(text); this.setOwnerPhone(phone); this.setOwnerEmail(email); } // getter to return the message ID public int getMesgID() { return mID; } // getter to return the owner's name public String getOwner() { return owner; } // getter to return the message text
Image of page 36
public String getText() { return text; } // getter to return the owner's phone number public int getOwnerPhone() { return ownerPhone; } // getter to return the owner's email address public String getOwnerEmail() { return ownerEmail; } //set the message ID public void setMesgID(int mID) { this.mID = mID; } // set the owner's name public void setOwner(String owner) { this.owner = owner; } // set the message text public void setText(String text) { this.text = text; } // set the owner's phone number public void setOwnerPhone(int ownerPhone) { this.ownerPhone = ownerPhone; } // set the owner's email address public void setOwnerEmail(String ownerEmail) { this.ownerEmail = ownerEmail; } }
Image of page 37
PartnerDescription.java package assignment1;
Image of page 38
Image of page 39

You've reached the end of your free preview.

Want to read all 39 pages?

  • One '14
  • Login, partner

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture