/*
* Class PropertyforRent with its data variable including id,address
and total rent
* */
class PropertyforRent
{
int id ;
String address;
double totalRent;
// Constructor for PropertyforRent which initialize its
Properties like Id, Address, totalRent
PropertyforRent(int x,String y,double z)
{
id=x;
address=y;
totalRent=z;
}
}
//Class HouseforRent
class HouseforRent extends PropertyforRent implements
Comparable
{
//properties of HouseforRent
double waterBill;
double electricityBill;
double gasBill;
/*Constructor of HouseforRent which initialize its properties
* It is derived class so its is necessary to call base constructor
at very first line
* in its own constructor
*
* */
public HouseforRent(double x,double y,double z,int id,String
address)
{
//Calling base class constructor(with id,address and rent which
include all expenses).This is the reason I use (x+y+z) as third
parameter.
super(id,address,x+y+z);
waterBill=x;
electricityBill=y;
gasBill=z;
}
//It is comparable interface method which needs to be
implemented
public int compareTo(Object obj)
{
//Compare on the basis of rent only
HouseforRent h=(HouseforRent)obj;
if(this.totalRent<h.totalRent) //rent
return 1;
else
return 0;
}
//this method in built call comparable method to compare objects
of two property
boolean isCheaper(HouseforRent h)
{
if(this.compareTo(h)==1)
return true;
else
return false;
}
}
/*
* Class CondoforRent
* */
class CondoforRent extends PropertyforRent implements
Comparable
{
//properties of CondoforRent
double maintenance;
double electricity;
/*Constructor of CondoforRent which initialize its
properties
* It is derived class so its is necessary to call base constructor
at very first line
* in its own constructor
*
* */
public CondoforRent(double x,double y,int id,String
address)
{
//Calling base class constructor(with id,address and rent which
include all expenses).This is the reason I use (x+y) as third
parameter.
super(id,address,x+y);
maintenance=x;
electricity=y;
}
//It is comparable interface method which needs to be
implemented
public int compareTo(Object obj)
{
CondoforRent c=(CondoforRent)obj;
if(this.totalRent<c.totalRent)
return 1;
else
return 0;
}
//this method in built call comparable method to compare objects of two property
boolean isCheaper(CondoforRent c)
{
if(this.compareTo(c)==1)
return true;
else
return false;
}
}
//This is Test Class
public class Test {
public static void main(String[] args)
{
//Creating two HouseProperty Objects
HouseforRent h1=new
HouseforRent(20,20,20,1,"Delhi");
HouseforRent h2=new
HouseforRent(30,20,500,1,"Chandigarh");
//comparing 2 objects
if(h1.isCheaper(h2)==true)
{
System.out.println("HouseProperty1
of rent "+h1.totalRent+" is cheaper than HouseProperty2");
}
else
System.out.println("HouseProperty2
of rent "+h2.totalRent+" is cheaper than HouseProperty1");
//Creating two CondoforRent property objects
CondoforRent c1=new
CondoforRent(20,20,1,"Delhi");
CondoforRent c2=new
CondoforRent(20,50,1,"Chandigarh");
//comparing 2 objects
if(c1.isCheaper(c2)==true)
{
System.out.println("CondoProperty1
of rent "+c1.totalRent+" is cheaper than CondoProperty2");
}
else
System.out.println("CondoProperty2
of rent "+c2.totalRent+" is cheaper than CondoProperty1");
}
}
![Console <terminated> test [Java Application] C:\Program Files Javaljre6bin javaw.exe (Dec 19, 2015 4:14:52 PM) ousePropertyl](http://img.homeworklib.com/questions/99947250-d501-11ea-b494-51028cfbfe9a.png?x-oss-process=image/resize,w_560)
Desing three classes A class named PropertyforRent to hold the following data: id: address totalRent indicates...
In Java(The Person, Student, Employee, Faculty, and Staff classes)Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and date hired. Define a class namedMyDate that contains the fields year, month, and day. A faculty member has office hours and a rank....
7. PersonData and CustomerData classes Design a class named PersonData with the following member variables : lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables . Next, design a class named CustomerData, which is derived from the PersonData class . The CustomerData class should have the following member variables : customerNumber mailingList The customerNumber variable will be used to hold a unique integer for each customer. The mailingList variable should be a bool....
using python to Design a class that holds the following personal data: name, address, age, and phone number. Write appropriate accessor and mutator methods. Also, write a program that creates three instances of the class. One instance should hold your information, and the other two should hold your friends’ or family members’ information.
C++ In the code cell below, define a class named Student with an integer id and a string name. This class should have a constructor that takes two arguments: one for the id and the other for the name. Then Create another class named CollegeStudent that publicly inherits from Student. This class should have a protected member named major. It should also have a constructor that takes three arguments: id, name, and major. This constructor should delegate initializing the id...
7. PersonData and CustomerData classes Design a class named PersonData with the following member variables: lastName firstName address city state zip phone Write the appropriate accessor and mutator functions for these member variables. Next, design a class named CustomerData, which is derived from the PersonData class. The CustomerData class should have the following member variables: customerNumber mailinglist The customer Number variable will be used to hold a unique integer for each customer. The mailing List variable should be a bool....
1. Design and implement classes. Design a class named Account and its two subclasses named Checking and Saving. Make Flexible and NotFlexbile subclasses of Saving. An account has a name, address, phone number, and balance. A checking account has a overdraft limit. A saving account has an interest rate. A flexible saving account has the accumulated interest rate. A none flexible account has the expected accumulated interest rate at the maturity of the account. Override the toString method in each...
Design and write a class named Employee that inherits the Person class from the previous exercise and holds the following additional data: ID number, department and job title. Once you have completed the Employee class, write a Python program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Phone Susan Meyers 47899 Accounting Vice President 212-555-1212 Mark Jones 39119 IT Programmer 212-555-2468 Joy Rogers 81774 Operations Engineer 212-555-9753 The Python program should store...
Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. Don't include a constructor or any other methods. Written in Python and formatted like it says below!!!!! Once you have written the class, write a program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Susan Meyers 47899 Accounting Vice President Mark Jones 39119 IT Programmer Joy Rogers 81774 Manufacturing Engineering...
Design a class named Student. The Student class should have a Firstname, a Lastname, an Address, an email address, a major and a GPA. Determine the data types for each property, then create the class diagram and write the pseudo-code that defines the class. You can use java language for pseudo-code
a. Create a class named Lease with fields that hold an apartment tenant's name, apartment Number, monthly rent amount, and term of the lease in months. Include a constructor that initializes the name. "XXX", the apartment number to O, the rent to 1000, and the term to 12. Also include methods to get and set each of the fields. Include a nonstatic method named addPetFee() that adds $10 to the monthly rent value and calls a static method named explainPetPolicy...