Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please finish this java program by following those requirement here is inside of employee java: // A class to represent employees in general. // Practice-IT

please finish this java program by following those requirement

image text in transcribed

image text in transcribed

here is inside of employee java:

// A class to represent employees in general. // Practice-IT Employee Class, changed a little by Iverson // Bellevue College, January 2020 // private base fields changed to static // added constructors for a name field // added toString to at least show name public class Employee { // Constructors and field added by Iverson // UW places fields at bottom, then changes for testing private String person; public Employee(String name) { person = name; } public Employee() { this("no name provided"); } public String toString() { return person; } // remaining code below from U.W. public int getHours() { return baseHours; // 40 hours/week }

public double getSalary() { return baseSalary; // $40,000.00 }

public int getVacationDays() { return baseVacationDays; // 10 days }

public String getVacationForm() { return baseVacationForm; // yellow }

// From UW: // These are so that test cases can change the base values // and make sure that subclasses also change their values. // (Your code that you submit is NOT supposed to directly use, call, // or modify the values below! They are here only to help Practice-It // successfully test your code. Please ignore them.) private static int baseHours = 40; private double baseSalary = 40000.0; private int baseVacationDays = 10; private String baseVacationForm = "yellow"; public final void setBaseHours(int hours) { baseHours = hours; } public final void setBaseSalary(double salary) { baseSalary = salary; } public final void setBaseVacationDays(int days) { baseVacationDays = days; } public final void setBaseVacationForm(String form) { baseVacationForm = form; } }

here is inside of item java:

/* * W.P. Iverson, January 2020 * copied from https://practiceit.cs.washington.edu/problems/bjp5/chapter9/GroceryBill.java * so we can work Exercise BJP5 Exercise 9.10: DiscountBill * * for Bellevue College, CS211 */

// Class used only for the GroceryBill Class // We use Item.java for other exercises public class Item { private String name; private double price; private double discount; public Item(String name, double price, double discount) { this.name = name; this.price = price; this.discount = discount; } public double getPrice() { return price; } public double getDiscount() { return discount; } private String valueToString(double value) { String result = "" + Math.abs(value); if(result.indexOf(".") == result.length() - 2) { result += "0"; } result = "$" + result; return result; } public String toString() { return name + " " + valueToString(price) + " (-" + valueToString(discount) + ")"; } }

here is inside of SimpleConsoleTest java:

import java.io.FileNotFoundException;

// version January 2021 // changed sku and numbers public class SimpleConsoleTest {

public static void main(String[] args) throws FileNotFoundException { Item one = new Item("Item #123020",13,2); // Item #123020 Item two = new Item("book",13,0); // a book at 13 System.out.println(one); // Item #123020 $13.00 (-$2.00) DiscountApp basket = new DiscountApp(); DiscountApp test = new DiscountApp(new Employee("you")); System.out.println(basket.getTotal()); // 0 System.out.println(basket.add(one,1)); // true System.out.println(basket); // Item #123020 $13.00 (-$2.00) System.out.println(basket.getTotal()); // 13 System.out.println(basket.add(one,8)); // true System.out.println(basket.getTotal()); // 104 System.out.println(basket.add(one,4)); // true System.out.println(basket.getTotal()); // 52 basket.add(two,9); System.out.println(basket.getTotal()); // 169 basket.setDiscount(true); System.out.println(basket.getTotal()); // 161 basket.setDiscount(false); System.out.println(basket.getTotal()); // 169 System.out.println(basket); // shows all, so output very long } }

here is inside of GroceryBill java:

import java.util.*;

public class GroceryBill { // FIELDS private Employee clerk; protected List receipt; private double total; private double internalDiscount; // CONSTRUCTORS public GroceryBill(Employee name) { clerk = name; receipt = new ArrayList(); total = 0.0; internalDiscount = 0.0; }

// Iverson requires zero parameter constructor public GroceryBill() { this(null); }

// MUTATORS (modifiers) public void add(Item i) { receipt.add(i); total += i.getPrice(); internalDiscount += i.getDiscount(); } // ACCESSORS (getters) public double getTotal() { return Math.rint(total * 100) / 100.0; } public Employee getClerk() { return clerk; } // private methods are called "helper" methods private String valueToString(double value) { value = Math.rint(value * 100) / 100.0; String result = "" + Math.abs(value); if(result.indexOf(".") == result.length() - 2) { result += "0"; } result = "$" + result; return result; } // complicated toString methods for Practice-IT output public String receiptToString() { String build = "items: "; for(int i = 0; i

}

. . Shopping App: (adapted from textbook programming Project #1, with significant changes) Submit DiscountApp.java which must extend GroceryBill D from Chapter 9 This programming project in our textbook has scant details, so I've wrote my own. It was based on the Discount Bill and GroceryBill from Chapter 9a, but a serious design flaw was uncovered: The "total" and "discount" in those textbook classes are always increase (+=) so we can never remove anything from the list. When you make a functioning shopping app, we need to be able to add AND remove items, so a design change is required. Bottom line, OK to extend GroceryBill, but total and discount must be recomputed in our subclass. In summary: Textbook ItemOrder will not be needed, because we can simply use Item from Chapter 9, and just add (or remove) Item objects in ArrayList With the simple change to "protected List" in the GroceryBill.java we can manipulate the ArrayList as needed. Search the ArrayList, managing size, super.add and remove become the major conceptual tasks in getting this project to work. Above specifications will impose good object-oriented programming (OOP) by using class methods to manipulate the object DiscountApp.java minimum specifications: one data field (NO more, others inherited) boolean for discount two constructors zero parameter and single parameter int number of Item's now purchased, return true upon add(Item, int) method success returns double, checks for discounts, cannot use super getTotal() method total set Discount(boolean) method simple one line of code, allows GUI App to work toString() standard calls toString() for all Items in cart In your solution, most coding is for add and getTotal, as they need to rework the List every time. Why the name "event driven Shopping"? Because we all must know that "event driven" programs are, as we use them constantly in daily life. Whenever an "event" happens, like a click or edit or data change, then some code is run and things happen, main() is not that important. I implement from Oracle, the ActionListener and extend JFrame so each "event" like a click or tab or enter key runs a method that calls your methods that totals our shopping cart in the app. It OT looks like this: preferred: false items: candy bar $1.35 (-$0.25) toy car $3.25 (-$8.50) apple $8.38 (-50.05) orange $8.30 (-$0.05) newspaper $0.99 (-$8.ee) get Total(): 6.19 preferred: true items: candy bar $1.35 (-$0.25) toy car $3.25 (-$0.50) apple $0.30 (-$0.05) orange $0.30 - $0.05) newspaper $0.99 (-$0.ee) sub-total: $6.19 discount: $0.85 total: $5.34 get Total(): 5.34 result: pass Above has picture has on the left ShoppingApp.java , overlaying the Practice-IT output from the Discount Bill exercise. GETTING STARTED: Some people like to start with just console code, so here are some simple tests that might be helpful by just getting the main() method to run in: SimpleConsoleTest.java This also requires from Chapter 9: Item.java Employee.java GroceryBill.java You can also create nearly empty classes and methods that are required to pass the compiler, doing trivial operations like "return 42;" when you see the real solution might be difficult. Eventually get the JFrame in ShoppingApp.java to show, then start adding code to complete the project....... Add classes to a Shopping App GUI, and make this GUI work: If you change the provided ShoppingApp driver, as we often do during development and debugging, be certain that the original ShoppingApp.java still works, else your code will not meet my specifications, and won't work when I test your solutions. Do no leave System.out calls in your final products (use as debug tool OK), and be sure your name is in all files submitted. No place in your DiscountApp.java should there be the "new" keyword, and no new object is needed for any of this assignment. You should simply call super() in your DiscountApp constructors and use super. in methods. No place in any of these Classes should you have "System.out" at all. You can use System.out for debugging and tests, but then remove it, as I should see a clean console free run of my JFrame GUI using your Classes, a real Java application. . . Shopping App: (adapted from textbook programming Project #1, with significant changes) Submit DiscountApp.java which must extend GroceryBill D from Chapter 9 This programming project in our textbook has scant details, so I've wrote my own. It was based on the Discount Bill and GroceryBill from Chapter 9a, but a serious design flaw was uncovered: The "total" and "discount" in those textbook classes are always increase (+=) so we can never remove anything from the list. When you make a functioning shopping app, we need to be able to add AND remove items, so a design change is required. Bottom line, OK to extend GroceryBill, but total and discount must be recomputed in our subclass. In summary: Textbook ItemOrder will not be needed, because we can simply use Item from Chapter 9, and just add (or remove) Item objects in ArrayList With the simple change to "protected List" in the GroceryBill.java we can manipulate the ArrayList as needed. Search the ArrayList, managing size, super.add and remove become the major conceptual tasks in getting this project to work. Above specifications will impose good object-oriented programming (OOP) by using class methods to manipulate the object DiscountApp.java minimum specifications: one data field (NO more, others inherited) boolean for discount two constructors zero parameter and single parameter int number of Item's now purchased, return true upon add(Item, int) method success returns double, checks for discounts, cannot use super getTotal() method total set Discount(boolean) method simple one line of code, allows GUI App to work toString() standard calls toString() for all Items in cart In your solution, most coding is for add and getTotal, as they need to rework the List every time. Why the name "event driven Shopping"? Because we all must know that "event driven" programs are, as we use them constantly in daily life. Whenever an "event" happens, like a click or edit or data change, then some code is run and things happen, main() is not that important. I implement from Oracle, the ActionListener and extend JFrame so each "event" like a click or tab or enter key runs a method that calls your methods that totals our shopping cart in the app. It OT looks like this: preferred: false items: candy bar $1.35 (-$0.25) toy car $3.25 (-$8.50) apple $8.38 (-50.05) orange $8.30 (-$0.05) newspaper $0.99 (-$8.ee) get Total(): 6.19 preferred: true items: candy bar $1.35 (-$0.25) toy car $3.25 (-$0.50) apple $0.30 (-$0.05) orange $0.30 - $0.05) newspaper $0.99 (-$0.ee) sub-total: $6.19 discount: $0.85 total: $5.34 get Total(): 5.34 result: pass Above has picture has on the left ShoppingApp.java , overlaying the Practice-IT output from the Discount Bill exercise. GETTING STARTED: Some people like to start with just console code, so here are some simple tests that might be helpful by just getting the main() method to run in: SimpleConsoleTest.java This also requires from Chapter 9: Item.java Employee.java GroceryBill.java You can also create nearly empty classes and methods that are required to pass the compiler, doing trivial operations like "return 42;" when you see the real solution might be difficult. Eventually get the JFrame in ShoppingApp.java to show, then start adding code to complete the project....... Add classes to a Shopping App GUI, and make this GUI work: If you change the provided ShoppingApp driver, as we often do during development and debugging, be certain that the original ShoppingApp.java still works, else your code will not meet my specifications, and won't work when I test your solutions. Do no leave System.out calls in your final products (use as debug tool OK), and be sure your name is in all files submitted. No place in your DiscountApp.java should there be the "new" keyword, and no new object is needed for any of this assignment. You should simply call super() in your DiscountApp constructors and use super. in methods. No place in any of these Classes should you have "System.out" at all. You can use System.out for debugging and tests, but then remove it, as I should see a clean console free run of my JFrame GUI using your Classes, a real Java application

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

Students also viewed these Databases questions

Question

manageremployee relationship deteriorating over time;

Answered: 1 week ago