<<<<<<<< I need only the UML diagram for ALL classes.Java????????????
public class House
{
private int houseNumber;
private int bedrooms;
private int sqFeet;
private int year;
private int cost;
public House(int houseNumber,int bedrooms,int sqFeet, int year, int cost)
{
this.houseNumber = houseNumber;
this.bedrooms = bedrooms;
this.sqFeet = sqFeet;
this.year = year;
this.cost = cost;
}
public int getHouseNumber()
{
return houseNumber;
}
public int getBedrooms()
{
return bedrooms;
}
public int getSqFeet()
{
return sqFeet;
}
public int getYear()
{
return year;
}
public int getCost()
{
return cost;
}
public boolean isExpensive()
{
if(cost>300)
return true;
return
false;
}
public boolean isNew()
{
if(year>=2000)
return true;
return
false;
}
public String toString()
{
return "HouseNumber: " + houseNumber + ", Bedrooms: " + bedrooms + ",SqFeet: " + sqFeet + ",Year:" + year +", Cost:" + cost +"\n";
}
}
*/
import java.util.ArrayList;
public class HouseComplex
{
public String toString(House[] list, int n)
{
if(n==0)
return "";
return toString(list, n-1) + list[n-1];
}
public void printExpensiveHouses(House[] list, int n)
{
if(n==0)
return;
printExpensiveHouses(list, n-1);
if(list[n-1].isNew())
System.out.print(list[n-1]);
}
public int countNew(House[] list, int n)
{
if(n==0)
return 0;
if(list[n-1].isNew())
return 1 + countNew(list, n-1);
return countNew(list, n-1);
}
private House min(House h1, House h2)
{
if(h1.getCost()>h2.getCost())
return h2;
return h1;
}
public House newestHouse(House[] list, int n)
{
if(n==1)
return list[0];
return min(list[n-1], newestHouse(list, n-1));
}
public ArrayList moderateSize(House[] list, int n)
{
ArrayList alist = new ArrayList();
if(n==0)
return alist;
if(list[n-1].getSqFeet()>=1000 && list[n-1].getSqFeet()<=2000)
{
alist.add(list[n-1]);
}
return moderateSize(list, n-1);
}
}
/**
* Write a description of class HouseCompex here.
*
*/
import java.io.*;
import java.util.*;
public class Tester
{
public static void main(String []args) throws IOException
{
Scanner sc = new Scanner(new File("inData.txt"));
House[] houseList = new House[100];
int houseNumber, bedrooms, sqFeet, year, cost, i;
for(i=0; sc.hasNext();i++)
{
houseNumber = sc.nextInt();
if(sc.hasNext()==false) break;
bedrooms = sc.nextInt();
sqFeet = sc.nextInt();
year = sc.nextInt();
cost = sc.nextInt();
houseList[i] = new House(houseNumber, bedrooms, sqFeet, year, cost);
}
HouseComplex hc = new HouseComplex();
System.out.println("Print all houses in the list:");
System.out.println(hc.toString(houseList, i));
System.out.println("Print all expensive houses in the list:");
hc.printExpensiveHouses(houseList, i);
System.out.println("\nPrint number of new houses in the list:");
System.out.println(hc.countNew(houseList, i));
System.out.println("Print the newest house in the list.:");
System.out.println(hc.newestHouse(houseList, i));
}
}
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
Get Answers For Free
Most questions answered within 1 hours.