Question: Please fill in shopping center.java 26 27 public boolean addToUserBalance (double amountToAdd)( 28 29 30 31This method allows the user to purchase T-Shirts. It takes

Please fill in shopping center.java

Please fill in shopping center.java 26 27 public boolean addToUserBalance (double amountToAdd)(28 29 30 31This method allows the user to purchase T-Shirts. Ittakes two parameters:amount, which represents 32 return false; the number of T-shirtsbeing purchased; and size, which represents the size of the shirts beingpurchased The prices for T-Shirts are as follows: small (represented by thecharacter 's or 'S): $10 each 34 35 36 37 38 39

26 27 public boolean addToUserBalance (double amountToAdd)( 28 29 30 31This method allows the user to purchase T-Shirts. It takes two parameters:amount, which represents 32 return false; the number of T-shirts being purchased; and size, which represents the size of the shirts being purchased The prices for T-Shirts are as follows: small (represented by the character 's or 'S): $10 each 34 35 36 37 38 39 40 41 42 43**/ 4 public boolean purchaseTShirts(int numTShirts, char size){ 45 46 47 medium (represented by the character 'm or 'M'): $20 each larges (represented by the character'1' or 'L'): $24 each Before allowing the purchase to go through, make sure it is a valid purchase first. Purchases can be invalid for a number of reasons. If the user does not have enough money, it is invalid. If the size character is invalid, the purchase is invalid. If they try to buy zero or a negative number of shirts, it is invalid. If a purchase is invalid, we will return false so that the error message can be shown by the main method. Otherwise we will subtract the cost from the user's balance and return true to signify that it is a valid purchase. return false; 1 import org.junit.Assert; 2 import static org.junit.Assert.*; import org.junit.Before; 4 import org.junit.Test; 6 7 public class ShoppingCenterTest { 9 private ShoppingCenter shop; 10 11Fixture initialization (common initialization * for all tests). */ 13 @Before public void setUp() { 14 15 16 17 18Tests getUserBalance just after creation*/ 19@Test public void getUserBalanceTest1) 20 21 shop - new ShoppingCenter); double result - shop.getUserBalance(); Assert.assertEquals( "Tests getUserBalance just after creation", 100, result, 0.001); 23 24/**Tests getUserBalance after a deposit **/ 25 Test public void getUserBalanceTest2() 26 27 shop.addToUserBalance (11.111); double result - shop.getUserBalance(); Assert.assertEquals( "Tests getUserBalance after a deposit", 111.111, result, 0.0001); 31* Tests getUserBalance after a purchase**/ 32 @Test public void getUserBalanceTest3) shop.purchaseTShirts(5, 'm); double result - shop.getUserBalance(); Assert.assertEquals( "Tests getUserBalance after a purchase", 0, result, 0.001); 35 37 38* Tests addToUserBalance in a simple way 39 @Test public void addToUserBalanceTest1) shop.addToUserBalance(100); shop.addToUserBalance (10) double result shop.getUserBalance ) Assert.assertEquals("Tests addToUserBalance in a simple way", 210, result, 0.001); 42 43 45 46* Tests addToUserBalance in a less simple way 47@Test public void addToUserBalanceTest2) 48 49 50 51 52 53 54 shop.addToUserBalance (100); boolean valid - shop.addToUserBalance (10); double result - shop.getUserBalance(); Assert.assertEquals("addToUserBalance returns correct value", true, valid); Assert.assertEquals ("addToUserBalance adds correctly", 210, result, 0.001); shop.addToUserBalance (44.4); result shop.getUserBalance(); Assert.assertEquals("Tests addToUserBalance with decimals", 254.4, result, 0.001); 56 57 58 * Tests addToUserBalance in a complex way/ 59@Test public void addToUserBalanceTest3() 60 61 62 63 64 65 shop.addToUserBalance (100); shop.addToUserBalance(10); double result shop.getUserBalance (); Assert.assertEquals("Tests addToUserBalance simply", 210, result, 0.001); boolean valid - shop.addToUserBalance(-100); result shop.getUserBalance( Assert.assertEquals("Tests addToUserBalance with negative values", 210, result, 0.001); Assert.assertEquals("Tests addToUserBalance returns correctly on negatives", false, valid); 67 68 69 70 *Tests addToUserBalance in a way more complex way*/ 71 @Test public void addToUserBalanceTest4() { 72 73 74 75 76 shop.addToUserBalance (100); shop.addToUserBalance (10); double result -shop.getUserBalance(); Assert.assertEquals("Tests addToUserBalance simply", 210, result, 0.001); boolean valid - shop.addToUserBalance(0)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!