- 3

Tests this program

Hi, I am having trouble with the tests for this program, can anyone help me? Tests: 1. one-parameter constructor correctly initializes instance variables 2. two-parameter constructor correctly initializes instance variables. 3. Tests state of customer account after purchasing one shirt. 4. Tests state of customer account after purchasing more than one shirt. 5. Tests state of customer account after multiple shirt purchases. 6. Tests state of customer account after purchasing more than one hat. 7. Tests state of customer account after multiple hat purchases Code for testing program: 1 public class CustomerAccount { 2 /* 3 * This class keeps track of a customer's purchases, 4 * total amount of thier purchases, and their balance. 5 * Note that the balance can be negative. 6 */ 7 8 //TODO 1: declare the instance variables to keep track of this customer's name, 9 // count of the number of shirts and hats purchased as well as the total 10 // amount purchased and the balance. 11 public String customerName; 12 private int numShirts; 13 private int numHats; 14 private double totalPurchased; 15 private double currentBalance; 16 17 static double totalPriceOfShirt,totalPriceOfHats; 18 19 /* 20 * A customer account must have a name. 21 * The other variables are initialized to zero. 22 */ 23 public CustomerAccount(String name){ 24 //TODO 2: Implement this method. 25 customerName = name; 26 } 27 28 /* 29 * A customer account must have a name, and may have a starting balance. 30 * The other variables are initialized to zero. 31 */ 32 public CustomerAccount(String customerName, double startBalance){ 33 //TODO 3: Implement this method. 34 this.customerName = customerName; 35 currentBalance = startBalance; 36 this.numShirts = 0; 37 this.numHats = 0; 38 this.totalPurchased = 0; 39 40 } 41 42 //TODO 4: Implement the following 5 "get" methods: 43 /* 44 * Returns the customer's name. 45 */ 46 public String getName(){ 47 return customerName; 48 } 49 50 /* 5

1st Jun 2020, 5:43 AM
Hanna Ngo
Hanna Ngo - avatar
1 Answer
0
Could you share that project link so I can access it. I don't want to waste my time copying and deleting all the unnecessary indexes. Click on the plus sign and then click on insert code.
3rd Jun 2020, 3:53 PM
rafalzacher1