Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

RealEstate.java /* * To change this license header, choose License Headers in Pr

ID: 3911142 • Letter: R

Question

RealEstate.java

/*

* To change this license header, choose License Headers in Project

Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

/**

*

* @author tieple

*/

public class RealEstate {

private int numberOfRoom;

private String furniture;

private int floor;

private String name;

private boolean isSellable;

private boolean isRentable;

private String airConditioning;

private boolean isShampooRequired;

private boolean isRepairNeeded;

private String color;

//non-parameterized constructor

public RealEstate()

{

numberOfRoom = 0;

furniture = "";

floor = 0;

name = "";

isSellable=false;

isRentable=false;

airConditioning = "";

isShampooRequired=false;

isRepairNeeded=false;

color = "";

}

public String getName()

{

return name;

}

public int getNumberOfRooms()

{

return numberOfRoom;

}

public String getFurnitureStatus()

{

return furniture;

}

public int getFloor()

{

return floor;

}

public boolean canSell()

{

return isSellable;

}

public boolean canRent()

{

return isRentable;

}

public boolean shampooRequired()

{

return isShampooRequired;

}

public boolean repairNeeded()

{

return isRepairNeeded;

}

public String getAirConditioningStatus()

{

return airConditioning;

}

public String getColor()

{

return color;

}

protected void setShampooRequired(boolean required)

{

isShampooRequired = required;

}

protected void setRepairNeeded(boolean needed)

{

isRepairNeeded = needed;

}

protected void setNumberOfRooms(int number)

{

numberOfRoom=number;

}

protected void setFurnitureStatus(String status)

{

furniture=status;

}

protected void setFloor(int floor)

{

floor=floor;

}

protected void setName(String newname)

{

name=newname;

}

protected void setSellingStatus(boolean status)

{

isSellable=status;

}

protected void setRentingStatus(boolean status)

{

isRentable=status;

}

protected void setAirConditioningStatus(String status)

{

airConditioning=status;

}

protected void setColor(String colour)

{

color = colour;

}

}

Car.java

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package CarTestExample;

/**

*

* @author tieple

*/

public class Car

{

// states or global variables

private int year;

private String make;

private String model;

private long miles;

private String color;

// constructor

public Car(int yr, String mk, String mdl, long mile, String clr)

{

year=yr;

make=mk;

model=mdl;

miles=mile;

color=clr;

}

//behaviors or methods

public int getYear()

{

return year;

}

public String getMake()

{

return make;

}

public String getModel()

{

return model;

}

public String getColor()

{

return color;

}

public long getMiles()

{

return miles;

}

public void setColor(String newcolor)

{

color=newcolor;

}

}

Q1) (40 Points) Imagine that you own a real estate agency that has been setup in Las Cruces Being a computer programmer yourself, you demand to have a template (class) that can retrieve basic information e.g., number of rooms, furniture, floor, air conditioning, etc., and that manages additional services you would offer e.g., shampooing carpets, repair requests, etc.; RealEstate.java is the template that was given to you. Your job is to go through RealEstate.java and do the following: - a) b) c) (5 Points) Enlist all the states or global variables of the class (5 Points) Enlist all the behaviors or methods of the class (15 Points) You notice that the class currently has a non-parameterized constructor and thus all states are initialized to 0, null or false by default. Your job is to introduce another constructor that is parameterized and gives you the ability to initialize the states (Hint: refer to the "Car" class in the notes supplied for week 2, i.e., CS152_452_Week2.zip) d) (15 Points) You see that there's no information about the rent if the property is rentable. Introduce an extra state "ren?" (int) and add "geteto" and "setRent(int newRent)" methods to the class. (Make necessary changes to RealEstate.java and submit it along with your homework, describing the steps taken by you as answers to the above questions c and d)

Explanation / Answer

q1)

a)The global variables/instance variables of real estate class are:

numberOfRoom

furniture

floor

name

isSellable

isRentable

airConditioning

isShampooRequired

isRepairNeeded

color

b)

The methods of real estate class are:

getName()

getNumberOfRooms()

getFurnitureStatus()

getFloor()

canSell()

canRent()

shampooRequired()

repairNeeded()

getAirConditioningStatus()

getColor()

setShampooRequired()

setRepairNeeded()

setNumberOfRooms()

setFurnitureStatus()

setFloor()

setName()

setSellingStatus()

setRentingStatus()

setAirConditioningStatus()

setColor()

c)

package cheggjuly;

public class RealEstate {

private int numberOfRoom;

private String furniture;

private int floor;

private String name;

private boolean isSellable;

private boolean isRentable;

private String airConditioning;

private boolean isShampooRequired;

private boolean isRepairNeeded;

private String color;

//non-parameterized constructor

public RealEstate()

{

numberOfRoom = 0;

furniture = "";

floor = 0;

name = "";

isSellable=false;

isRentable=false;

airConditioning = "";

isShampooRequired=false;

isRepairNeeded=false;

color = "";

}

public RealEstate(int noOfRooms,String furniture,int floor,String name,boolean isSellable,boolean isRentable,

String airConditioning,boolean isShampoorequired,boolean isRepairNeeded,String color){

this.numberOfRoom=noOfRooms;

this.furniture=furniture;

this.floor=floor;

this.name=name;

this.isSellable=isSellable;

this.isRentable=isRentable;

this.airConditioning=airConditioning;

this.isShampooRequired=isShampoorequired;

this.isRepairNeeded=isRepairNeeded;

this.color=color;

}

public String getName()

{

return name;

}

public int getNumberOfRooms()

{

return numberOfRoom;

}

public String getFurnitureStatus()

{

return furniture;

}

public int getFloor()

{

return floor;

}

public boolean canSell()

{

return isSellable;

}

public boolean canRent()

{

return isRentable;

}

public boolean shampooRequired()

{

return isShampooRequired;

}

public boolean repairNeeded()

{

return isRepairNeeded;

}

public String getAirConditioningStatus()

{

return airConditioning;

}

public String getColor()

{

return color;

}

protected void setShampooRequired(boolean required)

{

isShampooRequired = required;

}

protected void setRepairNeeded(boolean needed)

{

isRepairNeeded = needed;

}

protected void setNumberOfRooms(int number)

{

numberOfRoom=number;

}

protected void setFurnitureStatus(String status)

{

furniture=status;

}

protected void setFloor(int floor)

{

floor=floor;

}

protected void setName(String newname)

{

name=newname;

}

protected void setSellingStatus(boolean status)

{

isSellable=status;

}

protected void setRentingStatus(boolean status)

{

isRentable=status;

}

protected void setAirConditioningStatus(String status)

{

airConditioning=status;

}

protected void setColor(String colour)

{

color = colour;

}

}

d)

package cheggjuly;

public class RealEstate {

private int numberOfRoom;

private String furniture;

private int floor;

private String name;

private boolean isSellable;

private boolean isRentable;

private int rent;

private String airConditioning;

private boolean isShampooRequired;

private boolean isRepairNeeded;

private String color;

//non-parameterized constructor

public RealEstate()

{

numberOfRoom = 0;

furniture = "";

floor = 0;

name = "";

isSellable=false;

isRentable=false;

rent=0;

airConditioning = "";

isShampooRequired=false;

isRepairNeeded=false;

color = "";

}

public RealEstate(int noOfRooms,String furniture,int floor,String name,boolean isSellable,boolean isRentable,int rent,

String airConditioning,boolean isShampoorequired,boolean isRepairNeeded,String color){

this.numberOfRoom=noOfRooms;

this.furniture=furniture;

this.floor=floor;

this.name=name;

this.isSellable=isSellable;

this.isRentable=isRentable;

this.rent=rent;

this.airConditioning=airConditioning;

this.isShampooRequired=isShampoorequired;

this.isRepairNeeded=isRepairNeeded;

this.color=color;

}

public String getName()

{

return name;

}

public int getRent() {

return rent;

}

public void setRent(int rent) {

this.rent = rent;

}

public int getNumberOfRooms()

{

return numberOfRoom;

}

public String getFurnitureStatus()

{

return furniture;

}

public int getFloor()

{

return floor;

}

public boolean canSell()

{

return isSellable;

}

public boolean canRent()

{

return isRentable;

}

public boolean shampooRequired()

{

return isShampooRequired;

}

public boolean repairNeeded()

{

return isRepairNeeded;

}

public String getAirConditioningStatus()

{

return airConditioning;

}

public String getColor()

{

return color;

}

protected void setShampooRequired(boolean required)

{

isShampooRequired = required;

}

protected void setRepairNeeded(boolean needed)

{

isRepairNeeded = needed;

}

protected void setNumberOfRooms(int number)

{

numberOfRoom=number;

}

protected void setFurnitureStatus(String status)

{

furniture=status;

}

protected void setFloor(int floor)

{

floor=floor;

}

protected void setName(String newname)

{

name=newname;

}

protected void setSellingStatus(boolean status)

{

isSellable=status;

}

protected void setRentingStatus(boolean status)

{

isRentable=status;

}

protected void setAirConditioningStatus(String status)

{

airConditioning=status;

}

protected void setColor(String colour)

{

color = colour;

}

}