Step 3: Add a basic WineCase class and allow a buyer to select a case of wine to buy. Write a basic WineCase class to represent a case of wine. A WineCase object has four fields: refNo (a unique sequence of letters and digits), description (e.g. "chablis", "white burgundy" or similar), noOfBottles (in the case) and price (the price of the case in pounds). The constructor for the class should be passed suitable arguments to initialise these four fields. Add a selectWineCase() method to the Browser class which allows a browser to choose a case of wine provided that browser is a buyer. This method is passed a WineCase object as a parameter. You should declare a new field wineCase in the Browser class in order to store the case of wine selected. Make the selectWinecase() method print a message to the terminal window about the selection. An example is shown below: Buyer with ID 6732 has selected wine case with reference number LO786, a case of 2018 Pinot from Italy of 12 bottles at £120 Step 4: Allow a buyer to pay for the case of wine. Add a method payForWine() to the Browser This method will simply call a method in the Website class to pay for the wine i.e. to record the transaction with the website. And here we have a problem: at the moment the Website object does not record which browser has entered the store and, conversely, the Browser object also keeps no details of which site it has entered. Let’s deal with that now. b) Add another field website to the Browser This field will be used to store a reference (i.e. a pointer) to the website the browser is currently logged into. Write a mutator method setWebsite().
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Step 3: Add a basic WineCase class and allow a buyer to select a case of wine to buy.
- Write a basic WineCase class to represent a case of wine. A WineCase object has four fields: refNo (a unique sequence of letters and digits), description (e.g. "chablis", "white burgundy" or similar), noOfBottles (in the case) and price (the price of the case in pounds). The constructor for the class should be passed suitable arguments to initialise these four fields.
- Add a selectWineCase() method to the Browser class which allows a browser to choose a case of wine provided that browser is a buyer. This method is passed a WineCase object as a parameter. You should declare a new field wineCase in the Browser class in order to store the case of wine selected.
- Make the selectWinecase() method print a message to the terminal window about the selection. An example is shown below:
Buyer with ID 6732 has selected wine case with reference
number LO786, a case of 2018 Pinot from Italy of 12 bottles
at £120
Step 4: Allow a buyer to pay for the case of wine.
- Add a method payForWine() to the Browser This method will simply call a method in the Website class to pay for the wine i.e. to record the transaction with the website.
And here we have a problem: at the moment the Website object does not record which browser has entered the store and, conversely, the Browser object also keeps no details of which site it has entered. Let’s deal with that now.
- b) Add another field website to the Browser This field will be used to store a reference (i.e. a pointer) to the website the browser is currently logged into. Write a mutator method setWebsite().
Step by step
Solved in 2 steps with 6 images