for the following classes you are required to use private properties and include
ID: 3875185 • Letter: F
Question
for the following classes you are required to use private properties and include corresponding getters and setters…
Create an advanced enumeration to represent the months. Each enum should come with a friendlyName, shortName, daysInMonth, isLeapYearMonth, the zodiacSign, the zodiacStartDay and zodiacNextMonthEndDay
Tester
Properties
(ConcurrentHashMap()) rentals (Key is the apartment’s apartmentId)
Apartment
Properties
(string) apartmentId, address
(ConcurrentHashMap()) renters (Key is the renter’s renterId)
2 Constructors: Accepts: apartmentId, and address
Accepts: RandomAccessFile
Methods:
addRenter(Renter r)
save(RandomAccessFile raf), load(RandomAccessFile raf)
RenterProperties
(string) renterId, name
(ConcurrentHashMap()) items (Key is the item’s itemId)
2 Constructors: Accepts: renterId, and name
Accepts: RandomAccessFile
Methods
addItem(Item i)
save(RandomAccessFile raf), load(RandomAccessFile raf)
ItemProperties
(string) itemId, name
2 Constructors: Accepts: itemId, and name
Accepts: RandomAccessFile
Methods
save(RandomAccessFile raf), load(RandomAccessFile raf)
In the App class you should populate your tree of data starting with 3 Apartments, each rental has 4 renters, and each renter has 3 items. Save the data by calling the save for each apartment. This should cascade down the tree. Clear the rentals ConcurrentHashMap and then reload the entire structure (code below) and print the list
while(raf.getFilePointer() < raf.length())
Apartment a = new Apartment(raf);
rentals.put(a.apartmentId, a);
}
ITS A JAVA PROGRAM,AND THE PICTURE IS FOR "ADVANCING ENUMERATION"
Create the following Classes from : Aquarius January 20- February 18 Pisces February 19-March 20 Aries March 21-April 19 Taurus April 20- May 20 Gemini May 21 June 20 Cance June 21-July 22 leo July 23-August 22 Libra August 23-September 22September 23-October 22October 23- November 21 Virgo Scorpio Sagittarius Capricorn December 22- January 19 November 22-December 21Explanation / Answer
Answer 1: ZodiacEnum .java
---------------
package task2018;
public enum ZodiacEnum {
public enum ZodiacEnum {
AQUARIOUS("Aquarious", "Aquarious", 31, false, "AIR", 20, 18),
PISCES("Pisces","Pisces",28,true,"WATER",19,20),
ARIES("Aries","Aries",31,false,"FIRE",21,19),
TAURUS("Taurus","taurus",30,false,"EARTH",20,20),
GEMINI("Gemini","Gemini",31,false,"AIR",21,20),
CANCER("Cancer","Cancer",30,false,"WATER",21,22),
LEO("Leo","Leo",31,false,"FIRE",23,22),
VIRGO("Virgo","Virgo",31,false,"EARTH",23,22),
LIBRA("Libra","Libra",30,false,"AIR",23,23),
SCORPIO("Scorpio","Scorpio",31,false,"WATER",23,21),
SAGITTARIOUS("Sagittarious","Sagittarious",30,false,"FIRE",22,21),
CAPRICORN("Capricorn","Capricorn",31,false,"EARTH",22,19);
private String friendlyName;
private String shortName;
private int daysInMonth;
private boolean isLeapYearMonth;
private String zodiacSign;
private int zodiacStartDay;
private int zodiacNextMonthEndDay;
private ZodiacEnum(String friendlyName, String shortName, int daysInMonth,
boolean isLeapYearMonth, String zodiacSign, int zodiacStartDay,
int zodiacNextMonthEndDay) {
this.friendlyName = friendlyName;
this.shortName = shortName;
this.daysInMonth = daysInMonth;
this.isLeapYearMonth = isLeapYearMonth;
this.zodiacSign = zodiacSign;
this.zodiacStartDay = zodiacStartDay;
this.zodiacNextMonthEndDay = zodiacNextMonthEndDay;
}
public String getFriendlyName() {
return friendlyName;
}
public void setFriendlyName(String friendlyName) {
this.friendlyName = friendlyName;
}
public String getShortName() {
return shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public int getDaysInMonth() {
return daysInMonth;
}
public void setDaysInMonth(int daysInMonth) {
this.daysInMonth = daysInMonth;
}
public boolean isLeapYearMonth() {
return isLeapYearMonth;
}
public void setLeapYearMonth(boolean isLeapYearMonth) {
this.isLeapYearMonth = isLeapYearMonth;
}
public String getZodiacSign() {
return zodiacSign;
}
public void setZodiacSign(String zodiacSign) {
this.zodiacSign = zodiacSign;
}
public int getZodiacStartDay() {
return zodiacStartDay;
}
public void setZodiacStartDay(int zodiacStartDay) {
this.zodiacStartDay = zodiacStartDay;
}
public int getZodiacNextMonthEndDay() {
return zodiacNextMonthEndDay;
}
public void setZodiacNextMonthEndDay(int zodiacNextMonthEndDay) {
this.zodiacNextMonthEndDay = zodiacNextMonthEndDay;
}
}
----------------------------------------------------
Answer 2 : Tester.java
-----------------------------
package task2018;
import java.util.concurrent.ConcurrentHashMap;
public class Tester {
private ConcurrentHashMap<String, Apartment> rental = null;
private Tester() {
rental = new ConcurrentHashMap<String, Apartment>();
}
}
------------------------------------------
Answer 3: Apartment.java
------------------------------------
package task2018;
import java.io.RandomAccessFile;
import java.util.concurrent.ConcurrentHashMap;
public class Apartment {
private String apartmentId;
private String address;
private ConcurrentHashMap<String, Renter> renters = null;
private RandomAccessFile file = null;
private Apartment(String apartmentId, String address) {
super();
this.apartmentId = apartmentId;
this.address = address;
renters = new ConcurrentHashMap<String, Renter>();
}
private Apartment(RandomAccessFile file) {
this.file = file;
}
public String getApartmentId() {
return apartmentId;
}
public void setApartmentId(String apartmentId) {
this.apartmentId = apartmentId;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public ConcurrentHashMap<String, Renter> getRenters() {
return renters;
}
public void setRenters(ConcurrentHashMap<String, Renter> renters) {
this.renters = renters;
}
public void addRenter(Renter r) {
renters.put(r.getRenterId(), r);
}
public void save(RandomAccessFile raf) {
}
public void load(RandomAccessFile raf) {
}
}
---------------------------------------
Answer 4 : Renter.java
---------------------------------
package task2018;
import java.io.RandomAccessFile;
import java.util.concurrent.ConcurrentHashMap;
public class Renter {
private String renterId;
private String name;
private RandomAccessFile file = null;
private ConcurrentHashMap<String,Item> items = null;
private Renter(String renterId, String name) {
super();
this.renterId = renterId;
this.name = name;
items = new ConcurrentHashMap<String, Item>();
}
private Renter(RandomAccessFile file) {
this.file = file;
}
public String getRenterId() {
return renterId;
}
public void setRenterId(String renterId) {
this.renterId = renterId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public RandomAccessFile getFile() {
return file;
}
public void setFile(RandomAccessFile file) {
this.file = file;
}
public ConcurrentHashMap getItems() {
return items;
}
public void setItems(ConcurrentHashMap items) {
this.items = items;
}
public void addItem(Item i){
}
public void save(RandomAccessFile raf){
}
public void load(RandomAccessFile raf){
}
}
----------------------------------------
Answer 5 : Item.java
-------------------------------
package task2018;
import java.io.RandomAccessFile;
public class Item {
private String itemId;
private String name;
private RandomAccessFile file = null;
private Item(String itemId, String name) {
super();
this.itemId = itemId;
this.name = name;
}
private Item(RandomAccessFile file) {
this.file = file;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void save(RandomAccessFile raf) {
}
public void load(RandomAccessFile raf) {
}
}
-------------------------------------
Description
--------------------
1. As per the chegg policy, As an expert We need to answer first four question so please find the answer for first five question above as all the five question are related to class definition and for rest of the question you need to draft the same question again with updated code so that chegg expert provide you the best solution.
All the classes are compliable. Please let me know if you found any difficulties to use them.
2. I have provided all the class definition which includes constructor, properties , methods like properties setter,getter method and save and load.
3. For save and load method implementation you need to submit the question again as suggested above.
Thanks
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.