This is the question I am stuck on - 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 the following fields: sampleNumber - of type int description - A description of the type of rock (of type String) weight - The weight of the rock in grams (of type double) 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 using a method named setDescription inside of the constructor. This is what I am given -  import java.util.*; public class DemoRocks {    public static void main(String[] args)    {       // Write the demo program here    } } --------------------------- public class IgneousRock {    // Define the IgneousRock class here } ------------------------ public class MetamorphicRock {    // Define the MetamorphicRock class here } --------------------------- public class Rock {     // Define the Rock class here } ---------------------------------- public class SedimentaryRock {    // Define the Sedime

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

This is the question I am stuck on -

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 the following fields:

  • sampleNumber - of type int
  • description - A description of the type of rock (of type String)
  • weight - The weight of the rock in grams (of type double)

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 using a method named setDescription inside of the constructor.

This is what I am given - 

import java.util.*;
public class DemoRocks
{
   public static void main(String[] args)
   {
      // Write the demo program here
   }
}
---------------------------
public class IgneousRock
{
   // Define the IgneousRock class here
}
------------------------
public class MetamorphicRock
{
   // Define the MetamorphicRock class here
}
---------------------------
public class Rock
{
    // Define the Rock class here
}
----------------------------------
public class SedimentaryRock
{
   // Define the SedimentaryRock class here
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage