Quelpr

CAPE Computer Science Unit 2 · 2006 · Paper 2 · Question 6(a)

A company stores product data: name, inventory amount, reorder level, and price. A Product class must include these instance variables, a constructor, getters, a toString() method, and specific methods for reducing stock and determining reorder status.

Write the code for the Product class including the instance variables, constructor, accessor methods, toString() method, and the methods reduceItems(int amt) and reorder() as specified.

This question uses a figure or table from the paper — you'll see it when you practise.

The mark scheme is shown once you've answered.

Practise this question

Other parts of this question

  1. 6(b)(i)Write a code fragment to instantiate TWO Product objects using arbitrary data and assign them to separate variables.[2 marks]
  2. 6(b)(ii)Write a code fragment to create/instantiate a named data structure to store all Product objects and add the two Product objects from 6(b)(i) to it.[3 marks]
  3. 6(b)(iii)Write code to print the names of all Product objects in the data structure that need to be reordered.[5 marks]
  4. 6(c)Discuss the easiest way to reuse the functionality of the Product class in another application that requires additional instance variables and an alternate…[4 marks]

More practice: the rest of this paper · more Implementation, Testing, and Maintenance questions · all CAPE Computer Science Unit 2 past papers