Sample Output

Return to assignment description

The examples below show output from running my sample solution code on data files I have provided for you. Your program should produce nearly identical output when you paste in the values from the data files provided.

Recall that blue text indicates things typed by the user (or pasted in by the user), while the grey represent places where the user presses the Enter key (or line breaks in text pasted by the user).

Running TestFood with the original (stubby) Food class

isValidSodium("Valid"): OK isValidSodium("Another Valid"): OK isValidSodium(""): FAIL -- expected false but got true isValidSodium(null): FAIL -- expected false but got true ...press enter... isValidSize(10.000000): OK isValidSize(0.000000): FAIL -- expected false but got true isValidSize(-0.100000): FAIL -- expected false but got true ...press enter... isValidSodium(0.000000, 10.000000): OK isValidSodium(1000.000000, 1.000000): OK isValidSodium(-0.200000, 10.000000): FAIL -- expected false but got true isValidSodium(20000.000000, 10.000000): FAIL -- expected false but got true ...press enter... isValidCarbs(0.000000, 10.000000): OK isValidCarbs(1.000000, 1.000000): OK isValidCarbs(-0.200000, 10.000000): FAIL -- expected false but got true isValidCarbs(20.000000, 10.000000): FAIL -- expected false but got true ...press enter... addsUp(20.000000, 10.000000, 20.000000): OK addsUp(20.000000, 20.000000, 20.000000): FAIL -- expected false but got true addsUp(2000.000000, 0.100000, 2.000000): FAIL -- expected false but got true ...press enter... Valid 1 created: OK Valid 1's name: FAIL -- expected "Valid 1" but got null Valid 1's serving size: FAIL -- expected 10.0 but got 0.0 Valid 1's sodium content: FAIL -- expected 5.0 but got 0.0 Valid 1's carb content: FAIL -- expected 3.1 but got 0.0 Valid 2 created: OK Valid 2's name: FAIL -- expected "Valid 2" but got null Valid 2's serving size: FAIL -- expected 1.0 but got 0.0 Valid 2's sodium content: OK Valid 2's carb content: OK ...press enter... : FAIL -- did not throw IAE null: FAIL -- did not throw IAE ...press enter... Bad Serving 1: FAIL -- did not throw IAE Bad Serving 2: FAIL -- did not throw IAE ...press enter... Bad Sodium 1: FAIL -- did not throw IAE Bad Sodium 2: FAIL -- did not throw IAE Good Sodium 1 created: OK Good Sodium 1's name: FAIL -- expected "Good Sodium 1" but got null Good Sodium 1's serving size: FAIL -- expected 10.0 but got 0.0 Good Sodium 1's sodium content: FAIL -- expected 25.0 but got 0.0 Good Sodium 1's carb content: FAIL -- expected 3.1 but got 0.0 Good Sodium 2 created: OK Good Sodium 2's name: FAIL -- expected "Good Sodium 2" but got null Good Sodium 2's serving size: FAIL -- expected 1.0 but got 0.0 Good Sodium 2's sodium content: FAIL -- expected 1000.0 but got 0.0 Good Sodium 2's carb content: OK ...press enter... Bad Carbs 1: FAIL -- did not throw ISE Bad Carbs 2: FAIL -- did not throw ISE Good Carbs 1 created: OK Good Carbs 1's name: FAIL -- expected "Good Carbs 1" but got null Good Carbs 1's serving size: FAIL -- expected 10.0 but got 0.0 Good Carbs 1's sodium content: OK Good Carbs 1's carb content: FAIL -- expected 10.0 but got 0.0 ...press enter... Bad Sum 1: FAIL -- did not throw ISE ...press enter... Old Name 1's setName: FAIL -- expected "New Name" but got null Old Name 2's setName: FAIL -- no throw; name is now null Old Name 3's setName: FAIL -- no throw; name is now null ...press enter...

Running TestFood with a correctly completed Food class

isValidSodium("Valid"): OK isValidSodium("Another Valid"): OK isValidSodium(""): OK isValidSodium(null): OK ...press enter... isValidSize(10.000000): OK isValidSize(0.000000): OK isValidSize(-0.100000): OK ...press enter... isValidSodium(0.000000, 10.000000): OK isValidSodium(1000.000000, 1.000000): OK isValidSodium(-0.200000, 10.000000): OK isValidSodium(20000.000000, 10.000000): OK ...press enter... isValidCarbs(0.000000, 10.000000): OK isValidCarbs(1.000000, 1.000000): OK isValidCarbs(-0.200000, 10.000000): OK isValidCarbs(20.000000, 10.000000): OK ...press enter... addsUp(20.000000, 10.000000, 20.000000): OK addsUp(20.000000, 20.000000, 20.000000): OK addsUp(2000.000000, 0.100000, 2.000000): OK ...press enter... Valid 1 created: OK Valid 1's name: OK Valid 1's serving size: OK Valid 1's sodium content: OK Valid 1's carb content: OK Valid 2 created: OK Valid 2's name: OK Valid 2's serving size: OK Valid 2's sodium content: OK Valid 2's carb content: OK ...press enter... : OK -- message is "Illegal name: " null: OK -- message is "Illegal name: null" ...press enter... Bad Serving 1: OK -- message is "Illegal size: -1.5" Bad Serving 2: OK -- message is "Illegal size: 0.0" ...press enter... Bad Sodium 1: OK -- message is "Illegal sodium: -0.1" Bad Sodium 2: OK -- message is "Illegal sodium: 10000.1" Good Sodium 1 created: OK Good Sodium 1's name: OK Good Sodium 1's serving size: OK Good Sodium 1's sodium content: OK Good Sodium 1's carb content: OK Good Sodium 2 created: OK Good Sodium 2's name: OK Good Sodium 2's serving size: OK Good Sodium 2's sodium content: OK Good Sodium 2's carb content: OK ...press enter... Bad Carbs 1: OK -- message is "Illegal carbs: -3.1" Bad Carbs 2: OK -- message is "Illegal carbs: 10.1" Good Carbs 1 created: OK Good Carbs 1's name: OK Good Carbs 1's serving size: OK Good Carbs 1's sodium content: OK Good Carbs 1's carb content: OK ...press enter... Bad Sum 1: OK -- message is "Illegal sodium+carbs total" ...press enter... Old Name 1's setName: OK Old Name 2's setName: OK Old Name 3's setName: OK ...press enter...

Running original (stubby) A01 with correctly completed Food class

(introduction here)

Running correctly completed A01 with data from data1.txt

Sodium and Carbs Program ======================== Reads a list of foods from the user, then reports on which are low sodium and low carbs. By Mark Young (A00000000) ...press enter...(First Pause) How many foods do you have to check? 3 What is the name of this food? First Food What is the serving size (g)? 100 What is its sodium content (mg)? 40 What is the carb content (g)? 10 What is the name of this food? Second Food What is the serving size (g)? 150 What is its sodium content (mg)? 10.0 What is the carb content (g)? 15.7 What is the name of this food? Last Food What is the serving size (g)? 77.8 What is its sodium content (mg)? 0.1 What is the carb content (g)? 20 ...press enter...(Pause after data entry) List of All Foods: First Food (100g): 40mg sodium, 10g carbs Second Food (150g): 10mg sodium, 16g carbs Last Food (78g): 0mg sodium, 20g carbs ...press enter...(Pause after list printed) What is the most sodium allowed? 10.0 List of Low-Sodium Foods: Second Food (150g): 10mg sodium, 16g carbs Last Food (78g): 0mg sodium, 20g carbs ...press enter...(Pause after low sodium printed) What is the most carbs allowed? 15.5 List of Low-Carb Foods: First Food (100g): 40mg sodium, 10g carbs ...press enter...(Pause after low carbs printed)

Running correctly completed A01 with data from data2.txt

Sodium and Carbs Program ======================== Reads a list of foods from the user, then reports on which are low sodium and low carbs. By Mark Young (A00000000) ...press enter...(First Pause) How many foods do you have to check? 4 What is the name of this food? Was Bad Serving What is the serving size (g)? -1 The serving size must be positive. What is the serving size (g)? 0 The serving size must be positive. What is the serving size (g)? 200 What is its sodium content (mg)? 40 What is the carb content (g)? 10 What is the name of this food? Was Bad Carbs What is the serving size (g)? 150 What is its sodium content (mg)? 50 What is the carb content (g)? -10 The serving size cannot be negative. What is the carb content (g)? 80 What is the name of this food? Was Bad Sodium What is the serving size (g)? 800 What is its sodium content (mg)? -17 The serving size cannot be negative. What is its sodium content (mg)? -1 The serving size cannot be negative. What is its sodium content (mg)? -5 The serving size cannot be negative. What is its sodium content (mg)? 20 What is the carb content (g)? 10 What is the name of this food? The name cannot be empty. What is the name of this food? (Was Empty Name) What is the serving size (g)? 0.01 What is its sodium content (mg)? 0.0 What is the carb content (g)? 0.0 ...press enter...(Pause after data input) List of All Foods: Was Bad Serving (200g): 40mg sodium, 10g carbs Was Bad Carbs (150g): 50mg sodium, 80g carbs Was Bad Sodium (800g): 20mg sodium, 10g carbs (Was Empty Name) (0g): 0mg sodium, 0g carbs ...press enter...(Pause after printing list) What is the most sodium allowed? 0 List of Low-Sodium Foods: (Was Empty Name) (0g): 0mg sodium, 0g carbs ...press enter...(Pause after printing low sodium) What is the most carbs allowed? 0 List of Low-Carb Foods: (Was Empty Name) (0g): 0mg sodium, 0g carbs ...press enter...(Pause after printing low carbs)

Return to assignment description