Java Bootcamp – Workbooks and Challenges
)}

Vending Machine – Part 3

In this workbook, you will add a toString method to the Machine class. The method will return every item in the machine as a formatted String:

Task 1 – Add the toString method


Add the toString method and return a String variable temp that equals "".

Task 2 – Loop every item


Using a nested loop, append the toString of every item to the temp variable. Then, print the machine from main().

Task 3 – Separate each row


After the inner loop runs through an entire row, add two line separators \n\n to temp.

Task 4 – Tab of space


Add a tab of spacing before appending each row of items.

Task 5 – Aesthetics


After the nested loop runs to completion, add this line for aesthetics:

temp += "\t************************************************";

Feedback Summary
4.8
38 students
5

92%
4

3%
3

0%
2

0%
1

5%
Written Reviews
There are no written reviews yet.