Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use textpad, thank you here's the coin class:- /**************************************** * Coin.java * * Represents a coin that can be flipped ****************************************/public class Coin {private

please use textpad, thank you

here's the coin class:-image text in transcribed

/**************************************** * Coin.java * * Represents a coin that can be flipped ****************************************/public class Coin {private final int HEADS = 0; //tails is 1private int face; // current side showing/****************************** * sets up coin by flipping it * ****************************/public Coin() {flip();}/****************************** * set a random face value * ****************************/public void flip() {face = (int) (Math.random()*2);}/************************************* * returns true if the current face * value is heads and false otherwise * ***********************************/public boolean isHeads() {return (face == HEADS);}/****************************** * return current face value * ****************************/public String toString() {String result;if(face == HEADS)result = "Heads";elseresult = "Tails";return result;}}

Design and implement a class called MonetaryCoin that is derived from the given Coin class. Store a value in the monetary coin that represents its value and add a method that returns its value. Create a driver that instantiates and computes the sum of several MonetaryCoin objects and demonstrate that a monetary coin inherits its parent's ability to be flipped

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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago

Question

c. Will leaders rotate periodically?

Answered: 1 week ago