Question: I don't know how to write the method which have a yellow or green highlight pen. I need help with that. Also, I don't know
I don't know how to write the method which have a yellow or green highlight pen. I need help with that. Also, I don't know how to write a test program...



Here is what I got:
* * Item Class */ package model;
import java.text.NumberFormat; import java.util.Locale; import java.util.Objects; import java.math.BigDecimal;
public final class Item { private final String TheName; private final BigDecimal ThePrice; private int TheBulkQuantity; private BigDecimal TheBulkPrice; private final boolean TheBulkOption; public Item(final String theName, final BigDecimal thePrice) { this.TheName = Objects.requireNonNull(theName); if (thePrice.compareTo(BigDecimal.ZERO) == -1) { throw new IllegalArgumentException(); } this.ThePrice = Objects.requireNonNull(thePrice); this.TheBulkOption = false; } public Item(final String theName, final BigDecimal thePrice, final int theBulkQuantity, final BigDecimal theBulkPrice) { this.TheName = Objects.requireNonNull(theName); if (thePrice.compareTo(BigDecimal.ZERO) == -1 || theBulkQuantity
* * ItemOrder class * */
package model;
import java.util.Objects;
public final class ItemOrder { private final Item TheItem; private final int myQuantity; public ItemOrder(final Item theItem, final int theQuantity) { this.TheItem = Objects.requireNonNull(theItem); if (theQuantity
* * Cart class */
package model;
import java.math.BigDecimal; import java.util.Objects; import java.util.ArrayList; import java.util.List;
public class Cart { private boolean IsMember; private final List ItemOrders; public Cart() { this.ItemOrders = new ArrayList(); }
public void add(final ItemOrder theOrder) { for (int i = 0; i
public void setMembership(final boolean theMembership) { this.IsMember = theMembership; }
public BigDecimal calculateTotal() { BigDecimal total = BigDecimal.ZERO; BigDecimal result = BigDecimal.ZERO; for (int i = 0; i
@Override public String toString() { final StringBuilder display = new StringBuilder(128); display.append(this.getClass().getSimpleName()); display.append(", Item is at the shopping chart: "); display.append(this.ItemOrders.toString()); return display.toString(); } int compareTo(Cart other) { } int compare(Cart first, Cart second) { } }
I. Implementation Guidelines: 1. Please do the following cosmetic and layout changes on the GUI of the application to improve its look-and- feel. Please clearly mark your changes on the code with appropriate comments (e.g., #1.a - changes ...') to help us to locate your changes quickly. a. Change the Title of the window to identify the application more appropriately. For example, something like "PA#03 UW Bookstore Application" might be a better name. b. Change the colors of the panels to some other colors of your choice to improve its aesthetics. c. Append a Bookstore" postfix to the end of each Campus name, e.g., "Tacoma" will be replaced by "Tacoma Bookstore", and so on. d. Move the checkbox with the "customer has store membership label to the top panel under the library selection. Change the label name to something more meaningful. e. Move the "order total:" to the bottom panel, left of the "Clear" button. Change its label to something more meaningful. The "Clear" button should be displayed on the right on the bottom panel. f. Remove the "Seattle Bookstore from the list displayed at the top. Your new version will support only two bookstores. 2. Please provide implementations for the following methods of the Item class The rest of the methods may remain the same as before: a. String toString() Overrides the toString method in the Object class. returns a String representation of this Item: name, followed by a comma and a space, followed by price. See the provided examples in the textbook. b. boolean equals(Object other) Overrides the equals method in the Object class. returns true if the specified item is equivalent to this Item, and false otherwise. Two Items are equivalent if they have exactly equivalent names, prices, bulk quantities and bulk prices. See the provided template in the textbook. c. int hashCode() Overrides the hashCode method in the Object class. Returns the generated hash code for the object. See the examples in the textbook. int compareTo(Item other) Returns the result of comparison of the names of two Items alphabetically; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. dint Note that you should also implement the comparable Interface for the Item class. e. int compare(Item first, Item second) Returns the result of comparison of the prices of two Items; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. Note that you should also implement the Comparator Interface for the ten class. Hint: You will use this compare() method for the following purpose: If the selected bookstore is Bothell", then the items on the page are to be displayed in ascending price order. If the selected bookstore is "Tacoma", then the items on the page are to be displayed in descending price order. 3. Please provide implementations for the following methods of the Itemorder class The rest of the methods may remain the same as before: a. String toString() Overrides the toString method in the object class. b. boolean equals(Object other) returns a String representation of this Itemorder. It should contain the item description as given above and the quantity. Overrides the equals method in the object class. returns true if the specified item is equivalent to this Item, and false otherwise. Two Itemorders are equivalent if they have exactly equivalent items and quantities. Overrides the hashCode method in the object class. Returns the generated hashCode for the object. c. int hashCode() int compareTo(Itemorder other) Returns the result of comparison of the hash codes of two ItemOrders; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. Note that you should also implement the comparable Interface for the Itemorder class. 4. Please provide implementations for the following methods of the Cart class The rest of the methods may remain the same as before: a. String toString() Overrides the toString method in the object class. returns a String representation of this Itemorder. b. boolean equals(object other) Overrides the equals method in the object class. returns true if the specified item is equivalent to this Item, and false otherwise. Two items are equivalent if they have exactly equivalent Itemorders in the cart and their membership status are the same. c int hashCode Overrides the hashCode method in the object class. Returns the generated hashCode for the object. int compareTo(Cart other) Returns the result of comparison of the hash codes of two Carts; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. Note that you should also implement the comparable Interface for the Cart class. int compare(Cart first, Cart second) Returns the result of comparison of the hash codes of two Carts; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. Note that you should also implement the Comparator Interface for the Cart class. 5. Once you complete the above questions, replace the compare() method of Tacoma above with an appropriate Lambda Expression in your implementation. In other words, for the Bothell Bookstore there will be an object- oriented implementation, and for the Tacoma Bookstore there will be a lambda expression based implementation 6. Write the following test classes (a regular test class, not a JUnit test class) that will be able to access all the public methods of the above three classes: Cart, Itemorder, and Item. Your test classes will include the following methods for validation testing of your application. The validation testing is performed to prove that your program satisfies all the requirements mentioned in the assignment. Write a separate method for each new method you developed in the scope of this assignment - Each test method will print out the input parameters, expected result, and actual result: a. TestItem class with methods test_toString(args), test_equals(args), test_hashCode (args), and test_compareTo(args), b. TestItemorder class with methods test_toString(args), test_equals(args), test_hashCode(args), and test_compareTo(args), c. Test Cart class with methods test_toString(args), test_equals(args), test_hashCode (args), test_compareTo(args), and test_compare(args), Each test method should take one or more parameters as input, display test name, input parameters, the expected result, and computed actual result; return the result of their comparison as 1 to indicate "SUCCESS and -1 to indicate "FAIL" to the caller which will be print it out. In the main() method of the Test... classes, you read in or initialize the objects to be tested and call their test methods with one sample value to show that they are functioning correctly. The output might be something like the following: Test class running ... Test Item class running ... ... testing to_String with input(s): ... Expected result: ... Actual result: ... SUCCESS testing equals with input(s): ... Expected result: ... Actual result: ... SUCCESS BONUS PART: Find the action listeners (i.e., actionPerformed() methods) implemented with a Lambda Expression in the base source code, and replace them with object-oriented ActionListener interface implementations. And comment out the Lambda Expression based implementations. Mark them clearly (e.g. #7 implements ... ) so that I can find them easily and test both of your implementations by commenting out the alternative implementation easily. I. Implementation Guidelines: 1. Please do the following cosmetic and layout changes on the GUI of the application to improve its look-and- feel. Please clearly mark your changes on the code with appropriate comments (e.g., #1.a - changes ...') to help us to locate your changes quickly. a. Change the Title of the window to identify the application more appropriately. For example, something like "PA#03 UW Bookstore Application" might be a better name. b. Change the colors of the panels to some other colors of your choice to improve its aesthetics. c. Append a Bookstore" postfix to the end of each Campus name, e.g., "Tacoma" will be replaced by "Tacoma Bookstore", and so on. d. Move the checkbox with the "customer has store membership label to the top panel under the library selection. Change the label name to something more meaningful. e. Move the "order total:" to the bottom panel, left of the "Clear" button. Change its label to something more meaningful. The "Clear" button should be displayed on the right on the bottom panel. f. Remove the "Seattle Bookstore from the list displayed at the top. Your new version will support only two bookstores. 2. Please provide implementations for the following methods of the Item class The rest of the methods may remain the same as before: a. String toString() Overrides the toString method in the Object class. returns a String representation of this Item: name, followed by a comma and a space, followed by price. See the provided examples in the textbook. b. boolean equals(Object other) Overrides the equals method in the Object class. returns true if the specified item is equivalent to this Item, and false otherwise. Two Items are equivalent if they have exactly equivalent names, prices, bulk quantities and bulk prices. See the provided template in the textbook. c. int hashCode() Overrides the hashCode method in the Object class. Returns the generated hash code for the object. See the examples in the textbook. int compareTo(Item other) Returns the result of comparison of the names of two Items alphabetically; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. dint Note that you should also implement the comparable Interface for the Item class. e. int compare(Item first, Item second) Returns the result of comparison of the prices of two Items; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. Note that you should also implement the Comparator Interface for the ten class. Hint: You will use this compare() method for the following purpose: If the selected bookstore is Bothell", then the items on the page are to be displayed in ascending price order. If the selected bookstore is "Tacoma", then the items on the page are to be displayed in descending price order. 3. Please provide implementations for the following methods of the Itemorder class The rest of the methods may remain the same as before: a. String toString() Overrides the toString method in the object class. b. boolean equals(Object other) returns a String representation of this Itemorder. It should contain the item description as given above and the quantity. Overrides the equals method in the object class. returns true if the specified item is equivalent to this Item, and false otherwise. Two Itemorders are equivalent if they have exactly equivalent items and quantities. Overrides the hashCode method in the object class. Returns the generated hashCode for the object. c. int hashCode() int compareTo(Itemorder other) Returns the result of comparison of the hash codes of two ItemOrders; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. Note that you should also implement the comparable Interface for the Itemorder class. 4. Please provide implementations for the following methods of the Cart class The rest of the methods may remain the same as before: a. String toString() Overrides the toString method in the object class. returns a String representation of this Itemorder. b. boolean equals(object other) Overrides the equals method in the object class. returns true if the specified item is equivalent to this Item, and false otherwise. Two items are equivalent if they have exactly equivalent Itemorders in the cart and their membership status are the same. c int hashCode Overrides the hashCode method in the object class. Returns the generated hashCode for the object. int compareTo(Cart other) Returns the result of comparison of the hash codes of two Carts; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. Note that you should also implement the comparable Interface for the Cart class. int compare(Cart first, Cart second) Returns the result of comparison of the hash codes of two Carts; -1 if they are in ascending order, 0 if they are equal, and +1 if they are in descending order. Note that you should also implement the Comparator Interface for the Cart class. 5. Once you complete the above questions, replace the compare() method of Tacoma above with an appropriate Lambda Expression in your implementation. In other words, for the Bothell Bookstore there will be an object- oriented implementation, and for the Tacoma Bookstore there will be a lambda expression based implementation 6. Write the following test classes (a regular test class, not a JUnit test class) that will be able to access all the public methods of the above three classes: Cart, Itemorder, and Item. Your test classes will include the following methods for validation testing of your application. The validation testing is performed to prove that your program satisfies all the requirements mentioned in the assignment. Write a separate method for each new method you developed in the scope of this assignment - Each test method will print out the input parameters, expected result, and actual result: a. TestItem class with methods test_toString(args), test_equals(args), test_hashCode (args), and test_compareTo(args), b. TestItemorder class with methods test_toString(args), test_equals(args), test_hashCode(args), and test_compareTo(args), c. Test Cart class with methods test_toString(args), test_equals(args), test_hashCode (args), test_compareTo(args), and test_compare(args), Each test method should take one or more parameters as input, display test name, input parameters, the expected result, and computed actual result; return the result of their comparison as 1 to indicate "SUCCESS and -1 to indicate "FAIL" to the caller which will be print it out. In the main() method of the Test... classes, you read in or initialize the objects to be tested and call their test methods with one sample value to show that they are functioning correctly. The output might be something like the following: Test class running ... Test Item class running ... ... testing to_String with input(s): ... Expected result: ... Actual result: ... SUCCESS testing equals with input(s): ... Expected result: ... Actual result: ... SUCCESS BONUS PART: Find the action listeners (i.e., actionPerformed() methods) implemented with a Lambda Expression in the base source code, and replace them with object-oriented ActionListener interface implementations. And comment out the Lambda Expression based implementations. Mark them clearly (e.g. #7 implements ... ) so that I can find them easily and test both of your implementations by commenting out the alternative implementation easily
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
