Assignment 3 Task Specification [ITECH2306: XXXXXXXXXX] Assessment task: Assignment 3 Real-Estate Agency GUI-based Records System Overview You will develop a moderate-sized Java program with another...

1 answer below »
Here is the specs



Assignment 3 Task Specification [ITECH2306: 2021-07] Assessment task: Assignment 3 Real-Estate Agency GUI-based Records System Overview You will develop a moderate-sized Java program with another student, in order to demonstrate your understanding of topics from weeks 1 to 10. You are provided a detailed set of functional requirements which describe the behaviour that must be exhibited by the program you create. These are all detailed in the remainder of the assignment. Make sure you read it all carefully before you and your partner commence, so you understand what needs to be achieved. Finally, there are a range of suggested Tasks to be completed (see next page). If you have any questions about any of the requirements, please ask your teacher through their preferred means of communication. For this assignment, you should work with one other student only. Neither you nor the other student may get anyone else to do any of your work. You may be asked to attend a private interview with the marker to explain portions of the code before the assessment mark is finalised. Timelines and Expectations Percentage Value of Task:20% Due Date:Sunday 17th June at 11:59pm (end of Week 11) Minimum time expectation:8 hours Maximum time expectation:20 hours Learning Outcomes Assessed The following course learning outcomes are assessed to some degree, by completing this assessment: S1. Develop object-oriented programs involving several interacting classes. S2. Develop, compile and debug code using an appropriate IDE S3. Manage multiple versions of source code used to create separate software releases. S4. Select appropriate ways to represent data and collections of data. S5. Incorporate pre-written classes, including those from an API, into software solutions. S6. Develop object oriented programs which incorporate event driven aspects A1. Design, develop, test, debug and release programs from supplied program specifications. In particular, this assignment is focused on assessing your attainment of a range of the learning objectives of weeks 1 through 10 of the course, with an emphasis on the later weeks. For more detail on how you are marked, refer to the section at the back of this Task Specification document. ITECH2306 – Assignment 2 Task Specification (2021-07) Page 1 of 10 Tasks to be completed The following is a description of the tasks you and your partner may want to complete to address the needs of this assignment: 1. Read through the entire assignment task description to understand what the program needs to achieve and how you will be assessed. 2. Decide which of you will be Person 1, and which of you will be Person 2, as there are specific tasks to be done by each member of your small group. 3. You may like to develop a class diagram to organise your thoughts. (This is not marked.) 4. Decide a team name, perhaps made by combining your names. Then one of you needs to accept the GitHub Classroom assignment by clicking the link in Moodle (underneath the link you clicked to obtain this document) to create your team, then create your repository. Then the other student can accept the assignment and select the team created by the first student,, then you will both have access to the repository and will be able to clone/link it into your own IDE as you have done in some of the lab classes. 5. Start coding, by working on one functional requirement to start with. Develop code to address it. Once that functional requirement is fully addressed/working and tested, commit the code to the repository (you can commit more frequently if you wish), then take another functional requirement and repeat the process. Because you are now working with a partner, you will need to regularly pull and merge the work of your partner. Refer back to earlier week’s labs for assistance on merging (if required). Develop code to address further requirements. 6. Complete the individual documentation requirements. 7. Submit the completed work. Assessment Details Overview You are to develop a GUI-based application for use by a real estate agency. The real estate agency’s key customers are owners of properties that want to sell those properties, or owners of properties who want the agency to manage a lease/rental by a tenant of that property. The program ultimately needs to persist data about the properties, between each run of the program. To begin with you can read some default set of data from some files being provided to you. There are also a set of domain classes provided that you can use to commence your coding. The work for this assignment is to be done in pairs. Context/Background Information The real-estate agency is a business which interact with property owners, and either buyers or people called tenants who want to use a property that is owned by someone else (because the owner has decided that the property will be made available for a tenant to use, in exchange for a regular fee called the ‘rent’). The real- estate agency provides a service to the owners (and also to tenants): for example, by making available a list of properties for sale, a person can find out about the properties they might be interested to buy. In order to keep track of all the properties, and the owners of the properties, the agency wants a computer program which allows them to enter the information, and retrieve the information in the form of reports that they could print-out. Provided code files You are being provided with code files that implement the key domain classes: · Seller represents a type of Owner who wants to sell a property through the real-estate agency. Page 10 of 10 · Landlord represents a type of Owner who wants to let a tenant lease the property for a fee, paid through the real-estate agency (for convenience and for a degree of separation mediated by staff who are experienced in dealing with tenants). · SaleProperty represents a type of Property that is currently being marketed for sale to anyone who would like to buy it. · RentalProperty represents a type of Property that is currently being leased by a tenant. Provided Data Files You are provided with 2 data files that conform to the following described file-formats. The files use a format based on the style called CSV (Comma Separated Values), which means that each field of a record is separated by a comma, in a plain-text file. Microsoft Excel can interpret a CSV file and shows each field in a separate column. When marking your work, the marker may use different data files (e.g. with more data), but they will conform to the format describe below. Your program should work with any conforming data files. Property-Owners file (owners.csv): The very first line is a number, specifying how many ‘records’ follow in the file. There are then that many records on as many subsequent lines in the file. A record is a set of data items about an individual entity (in this case, properties). The format of each record for the property owners file is as follows: The first column of the line (up to the first comma) is the full name of the owner of the property. The second column is the address of the owner of the property. (Sometimes this is the address of the property such as if the property is the house of the owner.) The third column of the record is a unique “owner” code used by the Real Estate Agency to identify that owner. The fourth column of the record is a digit signifying whether this person is a Seller of a property (value 1), or the Landlord of a property that others can rent/lease (2). The remainder of the columns depend on whether the person is a Seller or a Landlord. If they are a Seller, then the remaining columns are as follows: · The fifth column is the name of their conveyancer (a person from the legal profession who is responsible for the legal representation of the seller on the day ownership will change to the new owner). If they are a Landlord, then the remaining columns are follows: · The fifth column is the bank account details of the owner (into which the collected rental fees needs to be paid). This is in the form of a BSB number (a 6 digit code identifying a specific bank branch) and then the bank account number after a colon. · The sixth column will be the amount of rent they receive each week from the tenants of the property Properties file (properties.csv): The very first line is a number, specifying how many ‘records’ follow in the file. There are then that many records on as many subsequent lines in the file. The format of each record for the property owners file is as follows: The first column of the line (up to the first comma) is the street address of a property. The second column of the line is the town/suburb in which the property is located. The third column of the line is a unique code to signify this property within the system. The fourth column of the line is a number which will correspond to one of the codes that uniquely identifies an owner (and which will appear in the property-owners file). The fourth column of the line is a digit indicating whether the property is for sale (1) or whether it is being leased (2). The remaining columns of the line depend on whether the property is for sale or for lease. If the property is for sale: · The fifth column will be the price (in dollars) that the owner hopes to receive from the sale. · The sixth column will be the area of the inside of the building, reported in square meters. If the property is being leased: · The fifth column will be the name of the primary person who is responsible for paying the rent (the tenant). · The sixth column will be the phone number of the tenants. Tasks for Person 1: Person 1 is responsible for coding the following parts of the program: · Reading the file containing the default set of Owners into memory when doing a ‘Reset’ (See FR-3) · Making the GUI Frame(s) for handling the process of adding a new Seller (See FR-5) · Making the GUI Frame(s) for handling the process of setting up a new leased property (See FR-8) · Writing a report about properties for sale to a text file (See FR-9) Tasks for Person 2: Person 2 is responsible for coding the following parts of the program: · Reading the file containing the default set of Properties into memory when doing a ‘Reset’ (See FR-4) · Making the GUI Frame(s) for handling the process of adding a new Landlord (See FR-6) · Making the GUI Frame(s) for handling the process of adding a new property for sale (See FR-7) · Writing a report about rental properties to a text file (See FR-10) Tasks to be divided/shared between both students: The remaining parts of the program should be divided/shared between each of you: · Creating a welcome screen (See FR-1) · Writing the current data
Answered 1 days AfterJun 19, 2021

Answer To: Assignment 3 Task Specification [ITECH2306: XXXXXXXXXX] Assessment task: Assignment 3 Real-Estate...

Shashi Kant answered on Jun 20 2021
152 Votes
Real-State/LeaseProperty.java
Real-State/LeaseProperty.java
import java.io.Serializable;
public class LeaseProperty implements Serializable{
  private String propertyAddress;
  private int totalProperties;
  private int propertyTaken;

  public void cancelLease(){
      if (propertyTaken>0)
        propertyTaken--;
   }

  public boolean takeProperty(){
     if (propertyTaken        propertyTaken++;
        return true;
     }
     else
        return false;
   }

  public int placesLeft(){
      return totalProperties - propertyTaken;
   }

  public int available(){
      return totalProperties - propertyTaken;
   }

  public LeaseProperty(String title, int totCapacity){
        this.propertyAddress = title;
        this.totalProperties = propertyTaken;
        propertyTaken = 0;
    }


  public LeaseProperty() {
        this("Address unknown", 0);
    }

  public void setPropertyAddress(String propAddress){
        this.propertyAddress = propAddress;
    }

   public void setTotalProperties(int totProperties){
        this.totalProperties = totProperties;
    }

   public String getPropertyAddress() { return propertyAddress;}
    public int getTotalProperties() { return totalProperties;}
    public int getPropertyTaken() { return propertyTaken;};


    public String toString() {
        return "\n Property Address: " + getPropertyAddress() + "\n Total Properties: " + getTotalProperties() + 
                "\n Property Taken: " + getPropertyTaken();
    }
}
Real-State/Property.java
Real-State/Property.java
import java.io.Serializable;
public class Property extends PropertyRent implements Serializable{

    private final int propertyID_;
    private String address_;
    private String beds_;
    private String propertyType_;
    private String rentAmount_;
    private String propertyStatus_;
    private static int nextPropertyID_ = 1;

    public Property(){
        propertyID_ = getNextPropertyID_();
        setAddress_("Unassigned");
        setBeds_("Unassigned");
        setPropertyType_("Unassigned");
        setRentAmount_("Unassigned");
        setPropertyStatus_("Unassigned");
    }

    public Property(String address, String beds, String pType, String rent, String pStatus){
        propertyID_ = getNextPropertyID_();
        nextPropertyID_++;
        setAddress_(address);
        setBeds_(beds);
        setPropertyType_(pType);
        setRentAmount_(rent);
        setPropertyStatus_(pStatus);
    }

    public int getPropertyID_(){
    return propertyID_;
    }

    public static int getNextPropertyID_(){
        if(HomeScreenGUI.propertyAvailable.isEmpty()){
            int Id = nextPropertyID_;
            nextPropertyID_++;
            return Id;
        }
        else{
            int Id = HomeScreenGUI.propertyAvailable.get(HomeScreenGUI.propertyAvailable.size() - 1).getPropertyID_();
            return (Id +1);
        }
    }

    public void setAddress_(String address){
        address_ = address;
    }

    public String getAddress_(){
    return address_;
    }

    public void setBeds_(String beds){
        beds_ = beds;
    }

    public String getBeds_(){
        return beds_;
    }

    public void setPropertyType_(String pType){
        propertyType_ = pType;
    }

    public String getPropertyType_(){
        return propertyType_;
    }

    public void setRentAmount_(String rent){
        rentAmount_ = rent;
    }

    public String getRentAmount_(){
        return rentAmount_;
    }

    public void 
setPropertyStatus_(String pStatus){
        propertyStatus_ = pStatus;
    }

    public String getPropertyStatus_(){
        return propertyStatus_;
    }

    public String toString(){
        return "\n" + super.toString()+ "\nProperty ID: " + this.getPropertyID_() + "\nAddress: " + this.getAddress_() +
            "\nBeds: " + this.getBeds_()  + "\nProperty Type: " + this.getPropertyType_()  + "\nRent Amount: " + this.getRentAmount_() +
                        "\nProperty Status: " + this.getPropertyStatus_();
    }
}
Real-State/Tenant.java
Real-State/Tenant.java
import java.io.Serializable;
public class Tenant extends Person implements Serializable {
    private final int tenantID;
    private String tenantStatus;
    private static int nextTenantID = 1;

    public Tenant(){
        super();
        setTenantStatus("Unknown");
        tenantID = getNextTenantID();
    }

    public Tenant(String name, String address, String phone, String pps, String tenStatus){
        super(name, address, phone, pps);
        tenantID = getNextTenantID();
        setTenantStatus(tenStatus);
    }

    public int getTenantID(){
    return tenantID;
    }

    public static int getNextTenantID(){
        if(HomeScreenGUI.tenantsAvailable.isEmpty()){
            int Id = nextTenantID;
            nextTenantID++;
            return Id;
        }
        else{
            int Id = HomeScreenGUI.tenantsAvailable.get(HomeScreenGUI.tenantsAvailable.size() - 1).getTenantID();
            return (Id +1);
        }
    }

    public void setTenantStatus(String tenStatus){
        tenantStatus = tenStatus;
    }

    public String getTenantStatus(){
    return tenantStatus;
    }

    public String toString(){
        return "\n" + super.toString()+ "\nTenant ID: " + this.getTenantID() + "\nTenant Status: " + this.getTenantStatus();
    }
}
Real-State/AmendTenantGUI.java
Real-State/AmendTenantGUI.java
import javax.swing.*;
import java.awt.*;
public class AmendTenantGUI extends JFrame {

    private static final int WIDTH = 800;
    private static final int HEIGHT = 500;

    private JLabel nameL, addressLine1L, addressLine2L, addressLine3L, countyL, tenantPhoneL, tenantPPSL, tenantStatusL,  tenantIDL, blankL, blank2L;
    private JTextField nameTF, addressLine1TF, addressLine2TF, addressLine3TF, countyTF, tenantPhoneTF, tenantPPSTF, tenantStatusTF, tenantIDTF;
    private String[] counties = {"Australia","India","Antrim","Armagh","Carlow","Cavan","Clare","Cork","Derry","Donegal","Down",
            "Dublin","Fermanagh","Galway","Kerry","Kildare","Kilkenny","Laois","Leitrim","Limerick","Longford","Louth","Mayo",
            "Meath","Monaghan","Offaly","Roscommon","Sligo","Tipperary","Tyrone","Waterford","Westmeath","Wexford","Wicklow"};
    private JComboBox countyComboBox;
    private JButton addB, cancelB;

    public static Tenant tenant_;

    public AmendTenantGUI(Tenant tenant){

        tenant_ = tenant;

        Font myFont = new Font("Times New Roman", Font.BOLD, 20);

        nameL = new JLabel("Tenant Name: " , SwingConstants.RIGHT);
        addressLine1L = new JLabel("Address Line 1: ", SwingConstants.RIGHT);
        addressLine2L = new JLabel("Address Line 2: ", SwingConstants.RIGHT);
        addressLine3L = new JLabel("Address Line 3: ", SwingConstants.RIGHT);
        countyL = new JLabel("County: ", SwingConstants.RIGHT);
        tenantPhoneL = new JLabel("Contact No: ", SwingConstants.RIGHT);
        tenantPPSL = new JLabel("Tenant's PPS Number: ", SwingConstants.RIGHT);
        tenantStatusL = new JLabel("Tenant Status: ", SwingConstants.RIGHT);
        tenantIDL = new JLabel("Tenant's ID Number: ", SwingConstants.RIGHT);
        blankL = new JLabel("", SwingConstants.RIGHT);
        blank2L = new JLabel("", SwingConstants.RIGHT);

        //Text Fields:
        nameTF = new JTextField(10);
        addressLine1TF = new JTextField(10);
        addressLine2TF = new JTextField(10);
        addressLine3TF = new JTextField(10);
        countyTF = new JTextField(10);
        tenantPhoneTF = new JTextField(10);
        tenantPPSTF = new JTextField(10);
        tenantStatusTF = new JTextField(10);
        tenantIDTF = new JTextField(10);
        tenantIDTF.setEditable(false);
        countyComboBox = new JComboBox(counties);

        nameTF.setText(tenant.getName());
        addressLine1TF.setText(tenant.getAddress());
        tenantPhoneTF.setText(tenant.getPhoneNumber());
        tenantPPSTF.setText(tenant.getPpsNumber());
        tenantStatusTF.setText(tenant.getTenantStatus());
        tenantIDTF.setText(""+tenant.getTenantID());

        addB = new JButton("Commit Changes");
        addB.setFont(myFont);
        addB.setToolTipText("Click to submit details to the system.\n NOTE: Make sure details are correct with landlord");
        addB.addActionListener(ae->{
            tenant.setName(nameTF.getText());
            tenant.setAddress(addressLine1TF.getText());
            tenant.setPhoneNumber(tenantPhoneTF.getText());
            tenant.setPpsNumber(tenantPPSTF.getText());
            tenant.setTenantStatus(tenantStatusTF.getText()); 
 
            tenantIDTF.setText(""+tenant.getTenantID());
            JOptionPane.showMessageDialog(null, "Tenant info updated!");
        });
                cancelB = new JButton("Cancel");
        cancelB.setFont(myFont);
        cancelB.addActionListener(ae->{
            setVisible(false);
            dispose();
        });

        setLayout(new GridLayout(11, 2));

        add(nameL);
        add(nameTF);
        add(addressLine1L);
        add(addressLine1TF);
        add(countyL);
        add(countyComboBox);
        add(tenantPhoneL);
        add(tenantPhoneTF);
        add(tenantPPSL);
        add(tenantPPSTF);
        add(tenantStatusL);
        add(tenantStatusTF);
        add(tenantIDL);
        add(tenantIDTF);
        add(blankL);
        add(blank2L);
        add(addB);
        add(cancelB);

        setTitle("Amend Tenant Details");
        setSize(WIDTH, HEIGHT);
        setLocationRelativeTo(null);
        setVisible(true);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        toFront();
    }
}
Real-State/HomeScreenGUI.java
Real-State/HomeScreenGUI.java
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JComboBox;
import javax.swing.JPanel;
public class HomeScreenGUI extends JFrame {
    public static ArrayList landlordList = new ArrayList<>();
    public static ArrayList propertyList = new ArrayList<>();
    public static ArrayList propertyLet = new ArrayList<>();
    public static ArrayList propertyAvailable = new ArrayList<>();
    public static ArrayList tenantsAvailable = new ArrayList<>();
    public static ArrayList tenantList = new ArrayList<>();
    public static ArrayList rentalList = new ArrayList<>();
    JTextArea area;
    String[] delPropertyLists = {"Properties Available", "Properties Least Out"};
    JComboBox delPropertyLts = new JComboBox(delPropertyLists);
    JButton b = new JButton("Enter");
    JButton c = new JButton("Cancel");
    JLabel delProText = new JLabel("Select Property List to delete from");
    String[] tenantLists = {"Tenants Available", "Tenants Not Available"};
    JComboBox tenantLts = new JComboBox(tenantLists);
    JButton d = new JButton("Enter");
    JButton f = new JButton("Cancel");
    JLabel tenText = new JLabel("Select Tenant List");
    String[] delTenantLists = {"Tenants Available", "Tenants Not Available"};
    JComboBox delTenantLts = new JComboBox(delTenantLists);
    JButton g = new JButton("Enter");
    JButton h = new JButton("Cancel");
    JLabel delTenText = new JLabel("Select Tenant List to delete from");
    String[] amdTenantLists = {"Tenants Available", "Tenants Not Available"};
    JComboBox amdTenantLts = new JComboBox(amdTenantLists);
    JButton i = new JButton("Enter");
    JButton j = new JButton("Cancel");
    JLabel amdTenText = new JLabel("Select Tenant List to delete from");
    String searchName;
    boolean found = false;
    public static void main(String args[]) throws IOException {
        HomeScreenGUI ex = new HomeScreenGUI();
        ex.setVisible(true);
    }
    public HomeScreenGUI() {
        Image storeImage = Toolkit.getDefaultToolkit().createImage("images/PropertyManagement.png");
        createMenuBar();
        loadDatabases();
        setLayout(new BorderLayout());
        setTitle("Real-Estate Agency");
        JLabel background = new JLabel(new ImageIcon(storeImage));
        add(background);
        background.setLayout(new FlowLayout());
        setSize(1218, 684);
        setResizable(false);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        area = new JTextArea();
    }
    private void createMenuBar() {
        JMenuBar menuBar = new JMenuBar();
        JMenu listMenu;
        ImageIcon exitIcon = new ImageIcon("images/exit.png");
        ImageIcon addIcon = new ImageIcon("images/add.png");
        ImageIcon deleteIcon = new ImageIcon("images/delete.png");
        ImageIcon editIcon = new ImageIcon("images/edit.png");
        ImageIcon searchIcon = new ImageIcon("images/search.png");
        ImageIcon displayIcon = new ImageIcon("images/display.png");
        ImageIcon listIcon = new ImageIcon("images/list.png");
        ImageIcon saveIcon = new ImageIcon("images/save.png");
        ImageIcon aboutIcon = new ImageIcon("images/about.png");
        ImageIcon helpIcon = new ImageIcon("images/help.png");
        JMenu file = new JMenu("File");
        file.setMnemonic(KeyEvent.VK_F);
        JMenu landlords = new JMenu("Landlords");
        landlords.setMnemonic(KeyEvent.VK_L);
        JMenu properties = new JMenu("Properties");
        properties.setMnemonic(KeyEvent.VK_P);
        JMenu tenants = new JMenu("Tenants");
        tenants.setMnemonic(KeyEvent.VK_T);
        JMenu rentals = new JMenu("Rentals");
        rentals.setMnemonic(KeyEvent.VK_R);
        JMenu help = new JMenu("Help");
        help.setMnemonic(KeyEvent.VK_H);
        JMenuItem save = new JMenuItem("  Save", saveIcon);
        save.setMnemonic(KeyEvent.VK_S);
        save.setToolTipText("Save any new changes made to the system");
        save.addActionListener(ae -> {
            saveDatabases();
            System.out.println("Save clicked");
        });
        JMenuItem exit = new JMenuItem("  Exit", exitIcon);
        exit.setMnemonic(KeyEvent.VK_E);
        exit.setToolTipText("Exit application");
        exit.addActionListener(ae -> {
            System.out.println("Exit option clicked");
            String message = " Would you like to save any changes made to the database? ";
            String title = "Quit";
            int confirm = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_CANCEL_OPTION);
            if (confirm == JOptionPane.YES_OPTION) {
                saveDatabases();
                JOptionPane.showMessageDialog(null, "Database updated. Goodbye");
                System.exit(0);
            } else if (confirm == JOptionPane.NO_OPTION) {
                JOptionPane.showMessageDialog(null, "Database not updated. Goodbye");
                System.exit(0);
            }
        }
        );
        file.add(save);
        file.addSeparator();
        file.add(exit);
        JMenuItem registerLandlord = new JMenuItem("  Register Landlord", addIcon);
        registerLandlord.setMnemonic(KeyEvent.VK_A);
        registerLandlord.setToolTipText("Open Register Landlord window");
        registerLandlord.addActionListener(ae -> {
            RegisterLandlordGUI addNewLandlordScreen = new RegisterLandlordGUI();
        });
        JMenuItem deRegisterLandlord = new JMenuItem("  De-Register Landlord", deleteIcon);
        deRegisterLandlord.setMnemonic(KeyEvent.VK_D);
        deRegisterLandlord.setToolTipText("De-Register Landlord from the system");
        deRegisterLandlord.addActionListener(ae -> {
            System.out.println("De-Register Landlord Clicked");
            Landlord removeLandLord = removeLandlord();
        });
        JMenuItem amendDetails = new JMenuItem("  Amend Details", editIcon);
        amendDetails.setMnemonic(KeyEvent.VK_C);
        amendDetails.setToolTipText("Find a Landlord and update their details");
        amendDetails.addActionListener(ae -> {
            System.out.println("Change Landlord Details Clicked");
            Landlord searchedLandL = amendLandlord();
            if (searchedLandL != null) {
                AmendLandlordGUI amendLandlordGUI = new AmendLandlordGUI(searchedLandL);
            }
        });
        JMenuItem searchLandlord = new JMenuItem("  Search Landlord", searchIcon);
        searchLandlord.setMnemonic(KeyEvent.VK_S);
        searchLandlord.setToolTipText("Search Landlord on the system");
        searchLandlord.addActionListener(ae -> {
            System.out.println("Search Landlord Clicked");
            Landlord seaLandlord = searchLandlord();
        });

        JMenuItem displayLandlord = new JMenuItem("  Display Landlords", displayIcon);
        displayLandlord.setMnemonic(KeyEvent.VK_L);
        displayLandlord.setToolTipText("Search Landlord on the system");
        displayLandlord.addActionListener(ae -> {
            System.out.println("Display Landlord Clicked");
            StringBuilder builder = new StringBuilder(landlordList.size());
            for (Landlord land : landlordList) {
                builder.append(land.toString() + "\n");
            }
            JTextArea textArea = new JTextArea(builder.toString());
            JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            scrollPane.setPreferredSize(new Dimension(500, 500));
            JOptionPane.showMessageDialog(null, scrollPane, "List of Landlords", JOptionPane.OK_OPTION);
            for (Landlord c : landlordList) {
                System.out.println(c.toString());
            }
        });
        landlords.add(registerLandlord);
        landlords.add(deRegisterLandlord);
        landlords.add(amendDetails);
        landlords.add(searchLandlord);
        landlords.add(displayLandlord);
        JMenuItem recordNewProperty = new JMenuItem("  Record New Property", addIcon);
        recordNewProperty.setMnemonic(KeyEvent.VK_R);
        recordNewProperty.setToolTipText("Open Record New Property window");
        recordNewProperty.addActionListener(ae -> {
            RecordNewPropertyGUI addNewPropertyScreen = new RecordNewPropertyGUI();
        });
        JMenuItem deleteProperty = new JMenuItem("  Delete Property", deleteIcon);
        deleteProperty.setMnemonic(KeyEvent.VK_D);
        deleteProperty.setToolTipText("Delete Property from the system");
        deleteProperty.addActionListener(ae -> {
            System.out.println("Delete Property Clicked");
            Property removeProperty = removeProperty();
        });
        JMenuItem searchProperties = new JMenuItem("  Search For Property", searchIcon);
        searchProperties.setMnemonic(KeyEvent.VK_A);
        searchProperties.setToolTipText("Search For a Property on the system");
        searchProperties.addActionListener(ae -> {
            System.out.println("Search For Property Clicked");
        });
        JMenuItem propertiesAvailable = new JMenuItem("  Display Properties Available", displayIcon);
        propertiesAvailable.setMnemonic(KeyEvent.VK_A);
        propertiesAvailable.setToolTipText("Search Properties on the system");
        propertiesAvailable.addActionListener(ae -> {
            System.out.println("Display Properties Clicked");
            StringBuilder builder = new StringBuilder(propertyAvailable.size());
            for (Property pr : propertyAvailable) {
                builder.append(pr.toString() + "\n");
            }

            JTextArea textArea = new JTextArea(builder.toString());
            JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            scrollPane.setPreferredSize(new Dimension(500, 500));
            JOptionPane.showMessageDialog(null, scrollPane, "List of Properties Available", JOptionPane.OK_OPTION);
            for (Property pro : propertyAvailable) {
                System.out.println(pro.toString());
            }
        });
        JMenuItem displayProperties = new JMenuItem("  Display Properties", displayIcon);
        displayProperties.setMnemonic(KeyEvent.VK_A);
        displayProperties.setToolTipText("Search Properties on the system");
        displayProperties.addActionListener(ae -> {
            System.out.println("Display Properties Clicked");
            StringBuilder builder = new StringBuilder(propertyList.size());
            for (Property pr : propertyList) {
                builder.append(pr.toString() + "\n");
            }
            JTextArea textArea = new JTextArea(builder.toString());
            JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            scrollPane.setPreferredSize(new Dimension(500, 500));
            JOptionPane.showMessageDialog(null, scrollPane, "List of Properties", JOptionPane.OK_OPTION);
            for (Property pro : propertyAvailable) {
                System.out.println(pro.toString());
            }
        });
        JMenuItem listPropertiesAvailable = new JMenuItem("  List Properties Available/Let", listIcon);
        listPropertiesAvailable.setMnemonic(KeyEvent.VK_L);
        listPropertiesAvailable.setToolTipText("List Properties Available/Let on the system");
        listPropertiesAvailable.addActionListener(ae -> {
            System.out.println("List Properties Available/Let Clicked");
            StringBuilder builder = new StringBuilder(propertyList.size());
            for (Property prop : propertyList) {
                builder.append(prop.toString() + "\n");
            }

            JTextArea textArea = new JTextArea(builder.toString());
            JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            scrollPane.setPreferredSize(new Dimension(500, 500));
            JOptionPane.showMessageDialog(null, scrollPane, "List of Properties not available", JOptionPane.OK_OPTION);
            for (Property p : propertyList) {
                System.out.println(p.toString());
            }
        });
        properties.add(recordNewProperty);
        properties.add(deleteProperty);
        properties.add(searchProperties);
        properties.add(displayProperties);
        properties.add(propertiesAvailable);
        properties.add(listPropertiesAvailable);
        JMenuItem registerNewTenant = new JMenuItem("  Register New Tenant", addIcon);
        registerNewTenant.setMnemonic(KeyEvent.VK_R);
        registerNewTenant.setToolTipText("Open Register New Tenant window");
        registerNewTenant.addActionListener(ae -> {
            RegisterNewTenantGUI addNewTenantScreen = new RegisterNewTenantGUI();
        });
        JMenuItem deleteTenant = new JMenuItem("  Delete Tenant", deleteIcon);
        deleteTenant.setMnemonic(KeyEvent.VK_D);
        deleteTenant.setToolTipText("Delete Tenant from the system");
        deleteTenant.addActionListener(ae -> {
            System.out.println("Delete Tenant Clicked");
            Tenant removeTenant = removeTenant();
        });

        JMenuItem amendTenant = new JMenuItem("  Amend Tenant's Details", editIcon);
        amendTenant.setMnemonic(KeyEvent.VK_C);
        amendTenant.setToolTipText("Find a Tenant and update their details");
        amendTenant.addActionListener(ae -> {
            System.out.println("Change Tenant Details Clicked");
            Tenant amendTenantDetails = amendTenant();
            if (amendTenantDetails != null) {
                AmendTenantGUI amendTenantGUI = new AmendTenantGUI(amendTenantDetails);
            }
        });

        JMenuItem searchTenant = new JMenuItem("  Search For Tenant", searchIcon);
        searchTenant.setMnemonic(KeyEvent.VK_S);
        searchTenant.setToolTipText("Search For a Tenant on the system");
        searchTenant.addActionListener(ae -> {
            System.out.println("Search For Tenant Clicked");
            Tenant searchTen = searchTenant();
        });

        JMenuItem tenantsAvailable = new JMenuItem("  Display Available Tenants", displayIcon);
        tenantsAvailable.setMnemonic(KeyEvent.VK_P);
        tenantsAvailable.setToolTipText("Display Tenants on the system");
        tenantsAvailable.addActionListener(ae -> {
            System.out.println("Display Tenants Clicked");
            String s = tenantLts.getSelectedItem().toString();
            if (s == "Tenants Available") {
                StringBuilder builder = new StringBuilder(HomeScreenGUI.tenantsAvailable.size());
                for (Tenant land : HomeScreenGUI.tenantsAvailable) {
                    builder.append(land.toString() + "\n");
                }
 
                JTextArea textArea = new JTextArea(builder.toString());
                JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                textArea.setLineWrap(true);
                textArea.setWrapStyleWord(true);
                scrollPane.setPreferredSize(new Dimension(500, 500));
                JOptionPane.showMessageDialog(null, scrollPane, "List of Tenants Available", JOptionPane.OK_OPTION);
                System.out.println("Tenant's Available List :");
                for (Tenant t : HomeScreenGUI.tenantsAvailable) {
                    System.out.println("Name: " + t.getName() + "\nID number: "
                            + t.getAddress() + "\nPhone No: " + t.getPhoneNumber() + "\nPPS Number: " + t.getPpsNumber()
                            + "\nTenant ID: " + t.getTenantID() + "\nTenant Status: " + t.getTenantStatus());
                }
            }
        });

        JMenuItem displayTenants = new JMenuItem("  Display Tenants List", displayIcon);
        displayTenants.setMnemonic(KeyEvent.VK_P);
        displayTenants.setToolTipText("Display Tenants on the system");
        displayTenants.addActionListener(ae -> {
            System.out.println("Display Tenants Clicked");
            String s = tenantLts.getSelectedItem().toString();
            if (s == "Tenants Available") {
                StringBuilder builder = new StringBuilder(tenantList.size());
                for (Tenant ten : tenantList) {
                    builder.append(ten.toString() + "\n");
                }
                JTextArea textArea = new JTextArea(builder.toString());
                JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
                textArea.setLineWrap(true);
                textArea.setWrapStyleWord(true);
                scrollPane.setPreferredSize(new Dimension(500, 500));
                JOptionPane.showMessageDialog(null, scrollPane, "List of Tenants Available", JOptionPane.OK_OPTION);
                System.out.println("Tenant's Available List :");
                for (Tenant t : HomeScreenGUI.tenantsAvailable) {
                    System.out.println("Name: " + t.getName() + "\nID number: "
                            + t.getAddress() + "\nPhone No: " + t.getPhoneNumber() + "\nPPS Number: " + t.getPpsNumber()
                            + "\nTenant ID: " + t.getTenantID() + "\nTenant Status: " + t.getTenantStatus());
                }
            }
        });
        tenants.add(registerNewTenant);
        tenants.add(deleteTenant);
        tenants.add(amendTenant);
        tenants.add(searchTenant);
        tenants.add(displayTenants);
        tenants.add(tenantsAvailable);
        JMenuItem processNewRental = new JMenuItem("  Process New Rental", addIcon);
        processNewRental.setMnemonic(KeyEvent.VK_P);
        processNewRental.setToolTipText("Process New Rental on the system");
        processNewRental.addActionListener(ae -> {
            System.out.println("Process New Rental Clicked");
            StringBuilder builder = new StringBuilder(rentalList.size());
            for (Rental land : rentalList) {
                builder.append(land.toString() + "\n");
            }
            int tenIdx = Integer.parseInt(JOptionPane.showInputDialog("Enter a tenant ID number "
                    + " between 1 and " + HomeScreenGUI.tenantsAvailable.size()));

            int propIdx = Integer.parseInt(JOptionPane.showInputDialog("Enter a property ID number "
                    + " between 1 and " + propertyAvailable.size()));
            Rental propertyRental = new Rental(propertyAvailable.get(tenIdx - 1),
                    HomeScreenGUI.tenantsAvailable.get(propIdx - 1));
            propertyAvailable.get(propIdx - 1).takeProperty();
            propertyRental.setTerm("1 year");
            propertyRental.setRate(750.00);
            rentalList.add(propertyRental);
            tenantList.add(HomeScreenGUI.tenantsAvailable.get(propIdx - 1));
            HomeScreenGUI.tenantsAvailable.remove(HomeScreenGUI.tenantsAvailable.get(propIdx - 1));
            propertyLet.add(propertyAvailable.get(tenIdx - 1));
            propertyAvailable.remove(propertyAvailable.get(tenIdx - 1));
        });
        JMenuItem searchRental = new JMenuItem("  Search For Rental", searchIcon);
        searchRental.setMnemonic(KeyEvent.VK_S);
        searchRental.setToolTipText("Search For a Rental on the system");
        searchRental.addActionListener(ae -> {
            System.out.println("Search For Rental Clicked");
        });
        JMenuItem displayRentals = new JMenuItem("  Display Rentals", displayIcon);
        displayRentals.setMnemonic(KeyEvent.VK_D);
        displayRentals.setToolTipText("Display Rentals on the system");
        displayRentals.addActionListener(ae -> {
            System.out.println("Display Rentals Clicked");
 
            area.setText("Class List\n");

            JScrollPane scroll = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            for (Rental r : rentalList) {
                area.append(r.toString());
                if (r.getProperty() instanceof Property) {
                    area.append(" for Class Name: " + ((Property) (r.getProperty())).getAddress_() + "\n\n");
                }
            }
 
            scroll.setPreferredSize(new Dimension(500, 500));
            JOptionPane.showMessageDialog(null, scroll);
        });
        rentals.add(processNewRental);
        rentals.add(searchRental);
        rentals.add(displayRentals);
        JMenuItem about = new JMenuItem("  About", aboutIcon);
        about.setMnemonic(KeyEvent.VK_A);
        about.setToolTipText("Information about this system");
        about.addActionListener(ae -> {
            System.out.println("Information about this system Clicked");
            JOptionPane.showMessageDialog(null, "This application is developed by Roman.\n"
                    + "This Project Is About Real-Estate Agency.");
        });

        JMenuItem documentation = new JMenuItem("  Help", helpIcon);
        documentation.setMnemonic(KeyEvent.VK_H);
        documentation.setToolTipText("Opens the help page. This shows information with regard to the operation of this system");
        documentation.addActionListener(ae -> {
            System.out.println("Display help page clicked");
            JOptionPane.showMessageDialog(null, "Click on the menu bar to use this software.\n"
                    + "You can use keyboard to handle this software also like press Alt then\n"
                    + "click on the fist alphabet of any menubar option.\n"
                    + "Ex- alt+L or alt+P or alt+ or alt+H");
        });
        help.add(about);
        help.add(documentation);
        menuBar.add(file);
        menuBar.add(landlords);
        menuBar.add(properties);
        menuBar.add(tenants);
        menuBar.add(rentals);
        menuBar.add(help);
        setJMenuBar(menuBar);
    }
    private void saveDatabases() {
        //Save the Landlord's File
        saveLandlordsFile();
        //Save the Properties Files
        savePropertiesListFile();
        savePropertiesFile();
        savePropertiesLetFile();
        //Save the Tenants Files
        saveTenantsFile();
        saveTenantsListFile();
        //Save the Rentals File
        saveRentalsFile();
    }
    private void saveLandlordsFile() {
        try {
            ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("files/landlords.data"));
            os.writeObject(HomeScreenGUI.landlordList);
            os.close();
        } catch (Exception e) {
            System.out.println("Error occurred when trying to save landlords.dat file");
            e.printStackTrace();
        }
        JOptionPane.showMessageDialog(null, "landlord(s) successfully written to file\n");
    }
    private void savePropertiesFile() {
        try {
            ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("files/property.data"));
            os.writeObject(HomeScreenGUI.propertyAvailable);
            os.close();
        } catch (Exception e) {
            System.out.println("Error occurred when trying to save properties.dat file");
            e.printStackTrace();
        }
        JOptionPane.showMessageDialog(null, "Property/Properties successfully written to file\n");
    }
    private void savePropertiesListFile() {
        try {
            ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("files/propertyList.data"));
            os.writeObject(HomeScreenGUI.propertyList);
            os.close();
        } catch (Exception e) {
            System.out.println("Error occurred when trying to save propertiesList.dat file");
            e.printStackTrace();
        }
        JOptionPane.showMessageDialog(null, "Property/Properties successfully written to file\n");
    }
    private void savePropertiesLetFile() {
        try {
            ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("files/propertyLet.data"));
            os.writeObject(HomeScreenGUI.propertyLet);
            os.close();
        } catch (Exception e) {
            System.out.println("Error occurred when trying to save propertiesLet.dat file");
            e.printStackTrace();
        }
        JOptionPane.showMessageDialog(null, "Property/Properties successfully written to file\n");
    }
    private void saveTenantsFile() {
        try {
            ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("files/tenants.data"));
            os.writeObject(HomeScreenGUI.tenantsAvailable);
            os.close();
        } catch (Exception e) {
            System.out.println("Error occurred when trying to save tenants.dat file");
            e.printStackTrace();
        }
        JOptionPane.showMessageDialog(null, "Tenant(s) successfully written to file\n");
    }
    private void saveTenantsListFile() {
        try {
            ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("files/tenantsList.data"));
            os.writeObject(HomeScreenGUI.tenantList);
            os.close();
        } catch (Exception e) {
            System.out.println("Error occurred when tr...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here