LocalResource(String date, String sector)- Actions of the constructor include accepting a date in the format “dd/mm/yyyy”, initializing the base class, storing the sector and storing an id as a consecutively increasing integer. Note that the constructor must ensure that the date of birth information is recorded. b. getId():Integer - returns the ID of the current instance of LocalResource c. getSector():String – returns the sector associated with the current instance of localResource d. getTRN():String – returns the trn number of the current instance of LocalResource. The process used to determine the TRN is to add the id to the number 100000000 and then returning the string equivalent. e. Update the NineToFiver class to ensure it properly extends the LocalResource class f. In method getContact() of NineToFiver, remove the comments so that the method returns "Local Employee #"+and the id of the contact. Write a concrete class LocalConsultant that extends LocalResource, and implements Citizen and Consultant. LocalConsultant exposes the following public methods: a. LocalConsultant(String dob, String sector, double skillPrice, double taxRate) Saves local instance data – populates superclass data and calculates and saves a permit tax for the instance with a value given by taxRate*skillPrice. b. earnFromSkill():double- return the skillPrice for the instance c. getContact():String – return the string value obtained by joining the text “LocalConsultant#” with the id associated with the person d. getPay():double – returns the value obtained by subtracting the permit tax from the value earned from the skill. Attempted code: class LocalResource extends Person { private static int idCounter = 0; private int id; private String sector; private String trn; // Constructor for LocalResource class // Accepts a date in the format "dd/mm/yyyy", initializes the base class, // stores the sector, and stores an ID as a consecutively increasing integer public LocalResource(String date, String sector) { super(); // Call the default constructor of the Person class for reference String[] parts = date.split("/"); super.setDob(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2])); this.sector = sector; this.id = ++idCounter; this.trn = getTRN(); } // Returns the sector associated with the current instance of LocalResource public String getSector() { return sector; } // Returns the ID of the current instance of LocalResource public int getId() { return id; } public String getTRN() { return String.valueOf(id + 100000000); } // Returns a string representation of the LocalResource object // in the format "[dd]LocalResource#id to be paid $pay in the sector sector" public String toString() { NumberFormat formatter = NumberFormat.getCurrencyInstance(); return "[" + super.getDobDay() + "]" + getContact() + " to be paid " + formatter.format(getPay()) + " in the " + sector + " sector"; } // Abstract method from the Person class that must be implemented // Returns the pay for the current instance of LocalResource @Override public double getPay() { return 0; } @Override public String getContact() { return "LocalResource#" + id; } } class LocalConsultant extends LocalResource implements Citizen, Consultant { private double skillPrice; private double permitTax; public LocalConsultant(String dob, String sector, double skillPrice, double taxRate) { super(sector, dob); this.skillPrice = skillPrice; this.permitTax = taxRate * skillPrice; } public double earnFromSkill() { return skillPrice; } public String getContact() { return "LocalConsultant#" + getId(); } public double getPay() { return earnFromSkill() - permitTax; } }
LocalResource(String date, String sector)- Actions of the constructor include accepting a date in the format “dd/mm/yyyy”, initializing the base class, storing the sector and storing an id as a consecutively increasing integer. Note that the constructor must ensure that the date of birth information is recorded. b. getId():Integer - returns the ID of the current instance of LocalResource c. getSector():String – returns the sector associated with the current instance of localResource d. getTRN():String – returns the trn number of the current instance of LocalResource. The process used to determine the TRN is to add the id to the number 100000000 and then returning the string equivalent. e. Update the NineToFiver class to ensure it properly extends the LocalResource class f. In method getContact() of NineToFiver, remove the comments so that the method returns "Local Employee #"+and the id of the contact.
-
Write a concrete class LocalConsultant that extends LocalResource, and implements Citizen and Consultant. LocalConsultant exposes the following public methods: a. LocalConsultant(String dob, String sector, double skillPrice, double taxRate)
- Saves local instance data – populates superclass data and calculates and saves a permit tax for the instance with a value given by taxRate*skillPrice. b. earnFromSkill():double- return the skillPrice for the instance c. getContact():String – return the string value obtained by joining the text “LocalConsultant#” with the id associated with the person d. getPay():double – returns the value obtained by subtracting the permit tax from the value earned from the skill.
- Attempted code:
-
class LocalResource extends Person {
private static int idCounter = 0;
private int id;
private String sector;
private String trn;// Constructor for LocalResource class
// Accepts a date in the format "dd/mm/yyyy", initializes the base class,
// stores the sector, and stores an ID as a consecutively increasing integer
public LocalResource(String date, String sector) {
super(); // Call the default constructor of the Person class for reference
String[] parts = date.split("/");
super.setDob(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
this.sector = sector;
this.id = ++idCounter;
this.trn = getTRN();
}// Returns the sector associated with the current instance of LocalResource
public String getSector() {
return sector;
}// Returns the ID of the current instance of LocalResource
public int getId() {
return id;
}public String getTRN() {
return String.valueOf(id + 100000000);
}// Returns a string representation of the LocalResource object
// in the format "[dd]LocalResource#id to be paid $pay in the sector sector"
public String toString() {
NumberFormat formatter = NumberFormat.getCurrencyInstance();
return "[" + super.getDobDay() + "]" + getContact() + " to be paid " +
formatter.format(getPay()) + " in the " + sector + " sector";
}// Abstract method from the Person class that must be implemented
// Returns the pay for the current instance of LocalResource
@Override
public double getPay() {
return 0;
}
@Override
public String getContact() {
return "LocalResource#" + id;
}
}class LocalConsultant extends LocalResource implements Citizen, Consultant {
private double skillPrice;
private double permitTax;
public LocalConsultant(String dob, String sector, double skillPrice, double taxRate)
{
super(sector, dob);
this.skillPrice = skillPrice;
this.permitTax = taxRate * skillPrice;
}
public double earnFromSkill()
{
return skillPrice;
}
public String getContact()
{
return "LocalConsultant#" + getId();
}
public double getPay()
{
return earnFromSkill() - permitTax;
}
}
![(217) C
78°F
Partly sunny
sml x
Answer y! LocalRe y! LocalRe y! LocalRe
✰ hackerrank.com/contests/comp1161-lab4-23/challenges/sml-worx-23/problem
199
200
201
202
203
204
205 }
Hi, Assi y! sml_wo y! Create
}
// Returns a string representation of the contact information for the current
// instance of LocalResource in the format "LocalResource#id"
@Override
public String getContact() {
return "LocalResource#" + id;
217
218 public double earnFromSkill() {
219
return permitTax;
220 }
221
222 public String getContact() {
223
224 }
225
226 public double getPay () {
227
228 }
229
230 }
231
232
233
234
235
236 class PayOrder implements Comparator<Person> {
237
public int compare (Person pl, Person p2)
238
{
229
return "LocalConsultant#" + getId();
return earnFromSkill()-permitTax;
206
207 class LocalConsultant extends LocalResource implements Citizen, Consultant {
208
209 private String skill;
210 private double permitTax;
211
212 public LocalConsultant (String dob, String sector, double skillPrice, double taxRate, String skill) {
213
super("", "", dob, sector);
214
this.skill skill;
215
this.permitTax = taxRate * skillPrice;
216 }
if (n1 go+Pay() >n2 getPay())
HII B-Rhym y! chatgp
O Search
■
ChatGP
H
Micros y! java co
ǝs Compa
Answer +
0
7:24 AM
2/14/2023
X
...](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2ca3eaf2-3bda-40e1-af2e-245059bd57cf%2F47e1acfc-a216-400e-81f8-4c8dcac128fc%2Fbepzg89_processed.png&w=3840&q=75)
![public class LocalResource extends Person {
private static int idCounter = 0;
private int id;
private String sector;
private String trn;
}
}
public LocalResource(String firstName, String lastName, String trn, String date, String sector) {|
super (firstName, lastName, date);
this.trn = trn;
this.sector = sector;
this.id = ++idCounter;
public String getSector() {
return sector;
}
public void setSector (String sector) {
this.sector = sector;
}
public int getId() {
return id;
}
public String getTRN () {
}
return Integer.toString(id +100000000);
public String getContact() {
return "LocalResource#" + Integer.toString(id);
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2ca3eaf2-3bda-40e1-af2e-245059bd57cf%2F47e1acfc-a216-400e-81f8-4c8dcac128fc%2Fllhqjl_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)