RHS   Allan   SW construction Exercises ECP03


 

ECP03

Create a project and a folder for this exercise.

Copy the following classes from ECP04: Book, CD, Product, ProductCatalog and TestProductCatalog.

The Browseproducts use case (see below) describes that browsing should be done in pages containing a maximum of 10 products

   

 

Now we'll adapt TestProductCatalog so it implements something like that - but to avoid having to enter more than 10 books we'll only have a maximum of 2 products at the time!

Rename the text of the "Show list" button into "Previous" and add a button labeled "Next":

   

To control which and how many products to show in the output area we need two things added to the code for the form:

The code for the "Previous" button should be changed according to the following instructions:

Hint: To add a number of Strings to a JTextArea you can add each String using the append() method.

The code for the "Next" button works in a similar way:

Run TestProductCatalog, enter a number of books and test that the two buttons work as they should - if not then correct your code!


Maintained by: Allan Helboe Nielsen
Updated: 3 November, 2005 1:04