Lab #5: Ch.4 Stock Manager
Preparation
Do the following before arriving at lab:
- Read our textbook's Sections 4.1–4.10.
- Bring your textbook to lab.
Objectives
After completing this lab, you should be able to:
- access data from an ArrayList
- use the for-each and while loop to solve problems
Main Exercises
- Open the Product project in the materials for Chapter 4.
- Open the StockManager class and add your name as another author.
- Exercise 4.36
- Exercise 4.37 (As the instructions specify,
your code needs to stop iterating if the product is found.)
- Exercise 4.38
(As the instructions indicate,
your code here needs to use
findProduct().)
- Exercise 4.39
(As the instructions imply,
your code here needs to use
findProduct().)
- Exercise 4.40
(As the instructions specify,
instead of using '
=='
to check whether
one String
is equal to another one,
you need to use '.equals()'.
Demonstrating StockManager
The project includes a class StockDemo to test the various methods in StockManager.
- Instantiate a StockDemo.
- Invoke the demo() method.
- Invoke sellProduct() with 132 as the argument.
- Invoke sellProduct() with 135 as the argument.
-
Make additions to StockDemo to test the additional methods you wrote for Exercise 4.40.
Turn in
Turn in a printout of your final version of the
source code StockManager.java,
and a printout of your demonstration using StockDemo.