Question: Create a class named Rock that acts as a superclass for rock samples collected and catalogued by a natural history museum. The Rock class contains

Create a class named Rock that acts as a superclass for rock samples collected and catalogued by a natural history museum. The Rock class contains fields for a number of samples, a description of the type of rock, and the weight of the rock in grams. Include a constructor that accepts parameters for the sample number and weight. The Rock constructor sets the description value to Unclassified. Include get methods for each field. Create three child classes named IgneousRock, SedimentaryRock, and MetamorphicRock. The constructors for these classes require parameters for the sample number and weight. Search the Internet for a brief description of each rock type and assign it to the description field. Create an application that instantiates an object of each type and demonstrate that the methods work appropriately. Save the files as Rock.java, IgneousRock.java, SedimentaryRock.java, MetamorphicRock.java, and DemoRocks.java.

Step by Step Solution

3.45 Rating (171 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class Rock private int sampleNumber private String description private double weight public R... View full answer

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 Java Programming Questions!