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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 2PE
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,