Professional Documents
Culture Documents
2)Create abstract class Toy with instance variable toyName,price and instance
method, setDetails( with three parameters)to set the values and getDetails() to
print the details of the Toy. Create one abstract method void discount() to
calculate the discount.Create sub class SoftToy and override discount() with a
discount of 20% of the toy price and print the discounted price.Create another
sub class PullToy and override discount() with a discount of 25% of the toy price
and print the discounted price.
Create a class ToyDemo and in main method create the object of both the sub
classes and using Run Time Polymorphism call all the methods. You can take hard
coded values to pass in the methods.
Override both the abstract methods in this class. When a user will deposit some
amount, balance will get increased and when amount is withdrawn using
withdraw method balance will be decreased, also in withdraw method apply a
check that a user cannot withdraw amount more than or equal to the balance give
appropriate message to user.
Finally create a class AccountDemo and create object of SavingAccount class and
call all the methods. Take all the values from user using Scanner class.