ava. Check ‘n Shop is a grocery supermarket in South Africa that provides a loyalty program to customers on a monthly basis. Customers earn points based on the number of visits and the amount they spend, especially on healthy foods during the month. The private data fields for the Shopper object class are: See attached image The constructor must assign values of the parameters to the private data field variables. The static variable should be incremented by one in the constructor. The increaseLoyaltyPoints() method calculates the number of loyalty points based on the amount a customer spent at the supermarket. All customers receive 100 free points e
java.
Check ‘n Shop is a grocery supermarket in South Africa that provides a loyalty program to customers on a monthly basis. Customers earn points based on the number of visits and the amount they spend, especially on healthy foods during the month.
The private data fields for the Shopper object class are: See attached image
The constructor must assign values of the parameters to the private data field variables. The static variable should be incremented by one in the constructor.
The increaseLoyaltyPoints() method calculates the number of loyalty points based on the amount a customer spent at the supermarket. All customers receive 100 free points each month. Use the following criteria to calculate the additional points earned to be added to the 100 free points:
- For every four rands (R4) spent, one loyalty point is awarded. Make use of an appropriate Math class function to round up the loyalty points to a whole number.
The updateHealthLevel() method receive the total amount spent on health food as a parameter. Calculate the percentage that was spent on healthy food and set the data field for the health level according to the criteria provided in the table below:
The customer earned more than 200 loyalty points and the shop was visited more than 5 times during the month, or the health level of the customer is platinum. The identifySmartShopper() method indicate whether the customer is a SMART shopper or not. A customer is a SMART shopper if the following applies:
- The string to be returned must either be “SMART Shopper” or an empty string.
The toString() method must compile a string to display all the attributes of the object on one line.
2. Create a testShopper class. Do the following:
Declare an array called arrShoppers of 10 Shopper type objects in the main method.
Write a static method in the test class called fillArray() to receive the array and number of objects created.
Use a while loop to enter the information (name of customer, number of visits, amount spent, amount spent on health foods).
Step by step
Solved in 5 steps with 5 images