Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program in Java. Given the below UML diagram, Gift - receiver: String price: double + Gift(receiver: String, price:double) + toString():String Client name: String - gifts:

image text in transcribed

Program in Java.

Given the below UML diagram, Gift - receiver: String price: double + Gift(receiver: String, price:double) + toString():String Client name: String - gifts: ArrayList + Client(name: String) + toString():String + getGifts():ArrayList + getName():String GiftCard Toy - category: char age: int + Toy(all-args) + toString():String + getCategory():char bankName: String amount: double + GiftCard (all-args) + getBankName():String + getAmount(): double toString():String setAmount (amount: double); void CharityGiftCard VisaGiftCard - designedby: String + CharityGiftCard (all-args) + toString():String + VisaGiftCard (all-args) + toString():String + refill(amount:double): void Consider the Gift, toy, GiftCard, CharityGiftCard, Visa Gift Card, Client classes described in the above UML. 1. Implement the class Gift. Note the following: The constructor takes as parameters the price and the receiver's name. If the price is negative the field price is assigned value 0. The toString method returns a description as follows: "The gift is offered to:...., it costs..... $" 2. Implement the class Toy. The constructor takes as parameters the receiver's name, the price, the age and the category. The category indicates the type of the toy. If the category is 'E', then the toy is electronic. If it is 'D' then it is Educational. The constructor checks if the category is E or D. If it is not then the category is set to U which means the category is undefined. The method toString returns a description as follows (use the super toString): "The toy category is ...., appropriate for age .... The gift is offered to:...., it costs:... $" For example: "the toy category is educational appropriate for age 5. The gift is offered to Mirna, it costs: 205" 3. Implement the class GiftCard: The constructor takes as parameters the receiver's name, the price, the bank name and the amount in dollars. The method toString returns a description as follows (use the super toString): "The giftcard is issued from ...bank, the amount is ...$. The gift is offered to:...., it costs:.... $" O 4. Implement the class CharityGiftCard. The method toString returns a description as follows (use the super toString): "It is a charity gift card designed by ... The giftcard is issued from ...bank, the amount is ...$. The gift is offered to:...., it costs..... $" 5. Implement the class VisaGiftCard: The constructor takes as parameters the receiver's name, the price, the bank name and the amount in dollars. The method refill takes an amount to refill the card. If the card is not empty the amount is incremented. the toString() method returns a description as follows: "It is a visa gift card. The giftcard is issued from ...bank, the amount is ...$. The gift is offered to:...., it costs:.... $" 6. Implement the class Client. The toString() method returns the name of the client and the list of gifts he bought for his/her friends. 7. Write the main program to: Create a client object. Add to the array: 2 toy objects of different categories, 1 GiftCare CharityGift Card, 1 VisaGiftCard, then add them to Client object. Count the number of electronic toys. Refill the visa card gifts with an amount of 200$. Display the details of all the gifts

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

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

Show that is a linear equation. f(x) = x (3.1.9)

Answered: 1 week ago

Question

Analyse the various techniques of training and learning.

Answered: 1 week ago