April 2000 QUESTION 3 Total Marks: 15 Marks |
Click here to access
other questions
Click to access |
Singapore Shoe Shop require a program to maintain details of their
stock.They stock three main types of shoes:sandal trainer and boot.
Every item of footwear has a size which is an integer in Singapore
Dollars,and a manufacturer which is a string. (a)Define a suitable enumerated type,called ShoeType which can take
on any of the three types of shoe.[1 mark ] (b)Declare a class Shoe used to store the details of a particular
pair of shoes,which contains the following: (c)The shop wishes to keep a record of all the shoes in stock.Give
a definition of a class Stock which contains two members,a dynamic
array of Shoe objects,called CurrentStock and an integer n specifying
the size of the array.[2 marks ] (d)The manager of the shop decides he would like to be able to search
his stock records for particular shoes.Give a definition of the function
Search the signature of which is given below,which takes four parameters,a
Stock object to be searched,the type of the shoe and the size of the
shoe to be searched for,and a reference to a Shoe which is used to
return a reference to the first shoe found which matches the criteria. (e)Assuming the Search function above was required to return a copy of the object found,instead of a reference to it,identify the type of function which would be best suited to perform this operation,and give an example signature for it.[2 marks ] |