Question
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
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 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started