Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a class named Shopper to represent a grocery store shopper. The class contains: A private int data field named items that specifies the number

Design a class named Shopper to represent a grocery store shopper. The class contains:

A private int data field named items that specifies the number of items in the shoppers cart (default is 0).

A private boolean data field named active that specifies whether the shopper is currently shopping (the default is false).

A private double data field named budget that specifies the amount the shopper can spend (the default is 100.00). This value is rounded to 2 decimal points

A string data field named location that specifies which section of the store the shopper is in (the default is entrance).

A no-arg constructor that creates a default shopper.

A method named details() that outputs a description for the shopper. If the shopper is active, the method prints the items in cart, active status, budget, and location of the shopper. If the shopper is not active, the method prints the shoppers budget and the text shopper is not in store.

Draw the UML diagram for the class. Write a program that creates three Shopper objects. For the first Shopper assign it the following values:

items use default

active use default

budget use default

location use default

For the second Shopper assign it the following values:

items 3

active true

budget 50.25

location Produce

For the third Shopper assign it the following values:

items 0

active false

budget 20.99

location use default

Call details() using each shopper. Create screenshots of the outputs.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Respond to personality differences among people.

Answered: 1 week ago