Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Given the Person class specified in Person.java file, fill in the code for the Employee class in the Employee.java fil 2. The Foodltem.java file

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

1. Given the Person class specified in Person.java file, fill in the code for the Employee class in the Employee.java fil 2. The Foodltem.java file defines a class called Foodltem that contains instance variables for name (String) and calories (int), along with get/set methods for both. Implement the methods in the Meal class found in Meal.java. 3. Consider the Customer class defined in Customer.java, which contains a double money variable. Add an isRicherThan(Customer other) method to the class that returns true if the calling Customer has more money than the Customer specified as an argument Write a static findRichest(Customerl customers) method that returns the Customer from the argument array that has the most money. Note: you do not need to handle the case of ties. 4. Create a Business class in a file called Business java. This class should store an array of Employee objects (use the class defined in Problem 1). Add a method to add employees to the Business, similar to addFoodltem in the Meal class. Add two more methods for the Business class: getHighestPaid(), which returns the Employee who has been paid the most in total, and getHighestTaxed(), which returns the Employee who has been taxed the most in total. Note: you do not need to handle the case of ties 5. Add static main methods to each of your classes to test their functionality. You should create various instances of the classes with different attributes and call some of the methods. Verify that your methods are functioning correctly in a variety of cases public class Person private String name; private int age; public Person(String iName, int iAge) name - Name; ageiAge; public String getName() return name; public int getAge()i return age public class Employee extends Person double weeklyBaseSalary; double totalPaid; double totalTaxed; public Employee(String iName, int iAge, double baseSal){ super(iName, iAge); //Code here * Should update the total amount paid/taxed for this employee * Taxes should be 10% of the weekly base salary for employees under the age of 30 * and 15% for employees aged 30 or older. * The total paid to the employee should be the amount remaining after taxes are paid public void pay) //Code here * Should return a String representing the employee's pay cheque. * The pay cheque must contain the following information: the employee' s name and age, * the weekly base salary, the amount paid in taxes, the amount paid to the employee. public String makePaycheque() //Code here return ""; //only included so code wi11 compile //Add any additional methods you require here //Represents a meal made up of up to maxItems food items public class Meal5 private FoodItem[] items; //stores all of the food items that are in the meal private static final int maxItems25; //Constructor should initialize all instance variables public Meal)( //Add the given food item to the items array, if there is still room //If there is no room, do nothing public void addFoodItem(FoodItem item)i //Return the FoodItem in the items array that has the largest number of calories //If there are ties, you may return any of the largest public FoodItem mostCalories ()( return null; //included so code will compile //Computes and returns the total number of calories of all food items in this meal public int calculateTotalcalories ()( return -1; //included so code will compile public class FoodItem private String name; private int calories; public FoodItem(String iName, int icals)( nameiName; calories -iCals; public void setName (String newName){ name - newName; public void setCalories (int newCals)1 caloriesnewCals; public int getCalories() return calories; public String getName()1 return name; public class Customer double money public Customer) this(0.0); public Customer (double initMoney)t money - initMoney; public double getMoney)( return money; public void setMoney (double newMoney) money - newMoney

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