Question

In: Computer Science

Please use very basic level of bluej thanks (please dont use advance techniques ) Write a...

Please use very basic level of bluej thanks (please dont use advance techniques )

Write a class House that represents a house. It should contain instance data: house number, street, town, year when the house was built. Define House’s constructor to accept and initialize all instance data. Include getter (accessor) and setter (mutator) methods for all instance data. Provide a toString method that returns one line description of the house as String. Provide method isHistoric() that returns a boolean indicating if the house was older than 50 from now or not.

Create a TestHouse class with main method in it. Within main method instantiate three House objects of your choice. At least one home should be historic. For each object invoke methods toString and isHistoric, and also invoke different pair of getter and setter methods. Provide appropriate print statements to explain the result of each invoked method to user.

Solutions

Expert Solution

CODE IN JAVA:

House.java file:

public class House {

private String houseNumber;

private String street;

private String town;

private int year;

House(String houseNumber,String street,String town,int year){

this.houseNumber = houseNumber;

this.street = street;

this.town = town;

this.year = year;

}

public String getHouseNumber() {

return this.houseNumber;

}

public String getStreet() {

return this.street;

}

public String getTown() {

return this.town;

}

public int getYear() {

return this.year;

}

public void setHouseNumber(String number) {

this.houseNumber = number;

}

public void setStreet(String street) {

this.street=street;

}

public void setTown(String town) {

this.town=town;

}

public void setYear(int year) {

this.year=year;

}

public String toString() {

return this.houseNumber+", "+this.street+", "+this.town+", "+this.year;

}

public boolean isHistoric() {

if(2019-year>50)

return true;

return false;

}

}

TestHouse.java file:

public class TestHouse {

public static void main(String[] args) {

House h1 =new House("1-16","raja street","tekkali",2000);

House h2 =new House("1-17","pedda street","palasa",1990);

House h3 =new House("1-18","golla street","uppal",1947);

System.out.println("The house1 is:"+h1);

if(h1.isHistoric())

System.out.println("house1 is historic");

System.out.println("The house2 is:"+h2);

if(h2.isHistoric())

System.out.println("house2 is historic");

System.out.println("The house3 is:"+h3);

if(h3.isHistoric())

System.out.println("house3 is historic");

}

}

OUTPUT:


Related Solutions

Please write code in SCALA Thanks in advance Use curried representation and write system which convert...
Please write code in SCALA Thanks in advance Use curried representation and write system which convert pressure units. Input: pressure in atm (atmosphere) Outputs: PSI, bar, torr 1 atm = 14.6956 psi = 760 torr = 101325 Pa = 1.01325 bar.
Please give a detailed explanation, not just the answer. Thanks in advance! Use the data in...
Please give a detailed explanation, not just the answer. Thanks in advance! Use the data in the given table to fill in the missing coefficients. Round your answers to 3 decimal places. x y 2 13.524 7.5 19.125 13 23.463 18.5 28.937 24 33.6 29.5 37.779 35 43.065 y=_____x +_______
please write about stakeholders approach in 200 words. thanks in advance. the topic is ''stakeholders approach''.
please write about stakeholders approach in 200 words. thanks in advance. the topic is ''stakeholders approach''.
USE C++ PLEASE AND EXPLAIN LINES AS MUCH AS POSSIBLE...THANKS IN ADVANCE...NEED THIS ASAP An unknown...
USE C++ PLEASE AND EXPLAIN LINES AS MUCH AS POSSIBLE...THANKS IN ADVANCE...NEED THIS ASAP An unknown number of grades as integers, but no more than 30, are to be read from the file grades.dat. You may assume each grade will be a valid value between 0 and 100 (no validation necessary) and all "grades" are out of a maximum 100 points. Output the Number of Grades read in from the file. Calculate and output the Total Points Earned. Calculate and...
Please answer the questions as soon as possible. Thanks in advance. Please explain in brief in...
Please answer the questions as soon as possible. Thanks in advance. Please explain in brief in one to two paragraphs and provide graphs. 1. In two paragraphs, describe the sources of the gains from trade and why countries use import tariffs. 2b In two paragraphs, describe how the COVID-19 pandemic has impacted the global macroeconomy and multiple ways it has impacted a specific agricultural commodity market (e.g. corn, beef, wheat).
interviews dos & dont, what are good interview techniques ? bad techniques? write in detail, three...
interviews dos & dont, what are good interview techniques ? bad techniques? write in detail, three to four pages
Please use Java language! with as much as comment! thanks! Write a program that displays a...
Please use Java language! with as much as comment! thanks! Write a program that displays a frame with a three labels and three textfields. The labels should be "width:", "height:", and "title:" and should each be followed by one textfield. The texfields should be initialized with default values (Example 400, 600, default title), but should be edited by the user. There should be a button (label it whatever you want, I don't care). If you click the button, a new...
Please use Java language! with as much as comment! thanks! Write a program that displays a...
Please use Java language! with as much as comment! thanks! Write a program that displays a frame with a three labels and three textfields. The labels should be "width:", "height:", and "title:" and should each be followed by one textfield. The texfields should be initialized with default values (Example 400, 600, default title), but should be edited by the user. There should be a button (label it whatever you want, I don't care). If you click the button, a new...
please provide me the tips to produce defect-free membrane (with references) Thanks in advance
please provide me the tips to produce defect-free membrane (with references) Thanks in advance
please answer it ASAP, Its URGENT!!! Thanks in advance Describe the entire path of the blood...
please answer it ASAP, Its URGENT!!! Thanks in advance Describe the entire path of the blood flow through the heart starting with blood returning to the heart from the body. Be sure to include each chamber, valve and vessel. Right and left are also important. (answer in ~250 words)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT