Question: To demonstrate your ability to design a simple class hierarchy and populate it with data. Also to show that you can store multiple objects of

To demonstrate your ability to design a simple class hierarchy and populate it with data. Also to show that you can store multiple objects of the class in an array and use it to perform some operations.
Specifications:
Create a new project called CoinToss and save it in the Lab 02 folder.
Step 1: Declare a base class called Coin that contains a Boolean data element called face, and a random generator to fill the face element with a Boolean value (true or false). True = heads, false = tails. The class needs a default constructor, a method to flip the coin, a method to return the face element, and a toString to display Heads if the face is true and Tails if not.
Step 2: Declare a subclass of Coin that describes what kind of coin it is and what value it represents. It needs a constructor that receives its value, a method that returns its value, and a toString method that returns a string with the face description (Heads or Tails) and its monetary value.
Step 3: Design and code a driver program that creates an array of 7 coins, assigns each a random coin value, flips them all, then sums the values of only the coins that are Heads, and finally displays all the coins and the sum.
Step 4: Using the JAVADOC format, document the program and every method (main is a method, not a constructor) as displayed in the sample programs found in the downloaded files for classroom activity. Completeness, accuracy, and spelling count.
Submit the whole project folder as a .zip file
yes it can be written in c++ preferably java though

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!