Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Starter Code: hw03/Employee.java package hw03; public class Employee implements Comparable { public String name, title; public int basePay, totalPay; public Employee(String name, String title, int
Starter Code:
hw03/Employee.java package hw03; public class Employee implements Comparable{ public String name, title; public int basePay, totalPay; public Employee(String name, String title, int basePay, int totalPay) { // TODO } @Override public int compareTo(Employee other) { // TODO: Compare Employee's only based on their names. return 0xbad; } @Override public String toString() { return String.format("Employee(\"%s\", \"%s\", %d, %d)", name, title, basePay, totalPay); } }
hw03/IllegalQueryException.java
package hw03; /** * Returned if EmployeeDataStore is given an illegal query. */ public class IllegalQueryException extends IllegalArgumentException { IllegalQueryException(String reason) { // TODO: An IllegalArgumentException can be created with a "message" or "reason" String... } }
hw03/EmployeeDataStore.java
package hw03; import java.io.FileNotFoundException; import java.io.IOException; import java.util.List; import java.util.Scanner; import java.util.Collections; // Collections.sort import java.util.NoSuchElementException; /** * EmployeeDataStore represents a set of Employees stored in a file in a simple text format where each Employee is * written out as four lines. For example, Employee("Mikel", "Human", 99999, 100000) would be stored in the file like * Mikel * Human * 99999 * 100000 */ public class EmployeeDataStore { private String filename; // TODO: Add any other members you might need public EmployeeDataStore(String filename) throws IOException { // TODO this.filename = filename; } /** * Reload the EmployeeDataStore from this.filename. If loading the Employees from a file fails, then the DataStore * should have the same employees as before. For example, if this.filename is deleted, then this.reloadDataStore is * called, an IOException will be thrown in the Scanner constructor and calling this.getEmployee or other methods * should behave as if this.reloadDataStore was not called (after this.filename was deleted). * @throws IOException */ public void reloadDataStore() throws IOException { // TODO } /** * Write the Employee objects in text format, sorted by name. This is kind of the inverse of .reloadDataStore(). * @throws FileNotFoundException */ public void saveDataStore() throws FileNotFoundException { // TODO: Save Employees in sorted order to this.filename; } /** * Returns a reference to an Employee with a particular name. If there's no such employee, return null; * @param name Name of employee, assuming all Employee.name's are unique. * @return A reference to an Employee in the DataStore. If it's modified, saving the DataStore will save changes. */ public Employee getEmployee(String name) { // TODO return null; } /** * Return a list of Employee that match the query. If any Employee object is modified, saving the DataStore will * save the changes. Throws IllegalQueryException if greaterThanName is greater than lessThanName * @param greaterThanName only return names greater than greaterThanName * @param lessThanName only return names less than lessThanName * @return a List of Employees matching the query * @throws IllegalQueryException */ public ListDescription I'm all about that Base... Data Base Your job is to finish implementing a simple Employee DataStore, which is like a DataBase but really simple Data Format (on disk) Each Employee object is written as four text lines with their name, title, basePay, and totalPay, like below: 2014-foothill-cs-simplified.txt William Murphy Instructor 99748 180789 Michael Loceff Instructor 99748 144740 Elaine Haight Instructor 99975 130809 Ladawn Meade Part-Time Faculty Instruct 70646 97262 Description I'm all about that Base... Data Base Your job is to finish implementing a simple Employee DataStore, which is like a DataBase but really simple Data Format (on disk) Each Employee object is written as four text lines with their name, title, basePay, and totalPay, like below: 2014-foothill-cs-simplified.txt William Murphy Instructor 99748 180789 Michael Loceff Instructor 99748 144740 Elaine Haight Instructor 99975 130809 Ladawn Meade Part-Time Faculty Instruct 70646 97262query(String greaterThanName, String lessThanName) throws IllegalQueryException { // TODO // TODO: Make sure when you throw an IllegalQueryException that you include helpful debug information. // Think about what a human seeing your error message would like to know when their program crashes. return null; } }
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