Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help creating a UML for a code. Please help! I wrote the code: public class RentalDueTest { public static void main(String[] args){ DBHandler

image text in transcribed

I need help creating a UML for a code. Please help! I wrote the code:

public class RentalDueTest { public static void main(String[] args){ DBHandler dbHandler = new DBHandler(); dbHandler.setupDB("rentalDB.txt");

//for testing ApartmentRental appt = new ApartmentRental(); appt.outputCurrentRent(dbHandler.getRentalProperties()); SingleFamilyRental sing = new SingleFamilyRental(); sing.outputCurrentRent(dbHandler.getRentalProperties()); } } ------------------------------------------------------------------------------------------------------------------------------ import java.util.ArrayList;

public class SingleFamilyRental extends RentalProperty implements Payment{ public SingleFamilyRental() {} public SingleFamilyRental(String rentalID, String numberRooms) { super.rentalType = "S"; super.rentalID = rentalID; super.numberRooms = numberRooms; }

@Override public void outputCurrentRent(ArrayList rentalProperties) { // prints out a formatted list of home IDs and their associated rents

System.out.print("Single Family Rental Summary: House ID Number Rent Amount Due ================ =============== "); for (int i=0 ; i

String outputFormatString; String rent = "...";

if (property.getRentalType().equals("S")) { if (property.getNumberRooms().equals("1")) { rent = " $936.00"; } else if (property.getNumberRooms().equals("2")) { rent = "$1144.00"; } else if (property.getNumberRooms().equals("3")) { rent = "$1352.00"; } outputFormatString = " " + property.getRentalID() + " " + rent; System.out.println(outputFormatString); } } System.out.println(" "); } } ------------------------------------------------------------------------------------------------------------------------------ public class RentalProperty { String rentalType; String rentalID; String numberRooms;

public RentalProperty() { }

public void outputCurrentRent() { System.out.println("ERROR: Can not output current rent"); }

public String getRentalType() { return rentalType; }

public String getRentalID() { return rentalID; }

public String getNumberRooms() { return numberRooms; } } ------------------------------------------------------------------------------------------------------------------------------ import java.util.ArrayList;

public class ApartmentRental extends RentalProperty implements Payment{ public ApartmentRental(){} public ApartmentRental (String rentalID, String numberRooms) { super.rentalType = "A"; super.rentalID = rentalID; super.numberRooms = numberRooms; }

@Override public void outputCurrentRent(ArrayList rentalProperties) { //prints a formatted list of Apartment IDs and their associated rent

System.out.print("Apartment Rental Summary: Apartment ID No. Rent Amount Due ================ =============== "); for (int i=0 ; i

String outputFormatString; String rent = " ......."; if (property.getRentalType().equals("A")) { if (property.getNumberRooms().equals("1")) { rent = " $648.00"; } else if (property.getNumberRooms().equals("2")) { rent = " $864.00"; } outputFormatString = " " + property.getRentalID() + " " + rent; System.out.println(outputFormatString); } } System.out.println(" "); } }

------------------------------------------------------------------------------------------------------------------------------ import java.util.ArrayList; interface Payment { void outputCurrentRent(ArrayList rentalProperties); } ------------------------------------------------------------------------------------------------------------------------------ import java.io.File; import java.util.ArrayList; import java.util.Scanner;

public class DBHandler {

private File file; private ArrayList rentalProperties = new ArrayList();

public void setupDB(String fileString) { //This will take a .txt database and parse it into a ArrayList file = new File(fileString); try { Scanner fileScan = new Scanner("rentalDB.txt"); while (fileScan.hasNextLine()) { String fileLine = fileScan.nextLine(); String[] prop = fileLine.split(" "); String propertyType = prop[0]; if (propertyType.equals("A")) { ApartmentRental a = new ApartmentRental(prop[1], prop[2]); rentalProperties.add(a); } else if(propertyType.equals("S")) { SingleFamilyRental s = new SingleFamilyRental(prop[1], prop[2]); rentalProperties.add(s); } } } catch (Exception ex) { ex.printStackTrace(); } }

public ArrayList getRentalProperties() { return rentalProperties; } }

However, I need help designing a UML for it. Please help! Thank you.

Problem Description A small real estate investor company in Albuquerque, New Mexico has conducted their residential rental business since 2010. Their business expanded from a few single-family houses to a few dozen houses and a couple of apartment complexes. The monthly rental fees for single-family house are 900.00, $1,100.00, and $1,300.00 for one, two, and three bedroom respectively. The monthly rental fees for apartment are $600.00 and $800.00 for one and two bedroom respectively. Due to the increase of business tax and other expenses, the company decided to increase the single- family house rent by 4% and the apartment rent by 8%. You are going to write a program to compute the rent for the two type rentals. In your program, you need to have at least the followings: a) An interface, Payment, for the two type of rentals to standardize the rent computation. b) A super class, Rental Property, for different rental properties c) Two subclasses: SingleFainlyRental and ApartmentRental for the two different rental properties. d) Apply polymorphism to print the rent due using a method, Outputcurrent Rent You need to open a text file, rentalDB, and get the rental information for your program. The record format of zentalDB as follows: Field 1: rental type-5 means single-family rental, A means apartment rental Field 2: rental ID-a7 characters rental property identification Field 3: number of bedrooms-1 means 1-bedroom, 2 means 2-bedroom, 3 means 3-bedroom Note: A blank separates two fields. Example of the rentalDB text file as follow: S SABQ138 3 A AABQ205 2 S SABQ127 1 S SAB0126 2 The above example represents: Single-family rental, ID number SABQ138, three bedrooms Apartment rental, ID number AABQ205, two bedrooms Single family rental, ID SABQ127, one bedroom The output of your method OutputCurrentRent method should look like the following (sort the output by the number of bedrooms followed by the rental unit ID number): Single-Family Rental Summary: louse 1D Nunber of Bedrooms Rental Due SABQ138 SABQ126 SABQ127 $1,352.00 1,144.00 936.00 Apartment rental Surmary: Apartment ID No. of Bedrooms Rental Due AABQ127 AABQ126 9864.00 9648.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

design a simple disciplinary and grievance procedure.

Answered: 1 week ago