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."

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 1DE
icon
Related questions
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 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."

A. Command Prompt
D:\JavaBatchFile>javac Rock.java
D:\JavaBatchFile>javac IgneousRock.java
D:\JavaBatchFile>javac MetamorphicRock.java
D:\JavaBatchFile>javac SedimentaryRock.java
D:\JavaBatchFile>javac DemoRocks.java
D:\JavaBatchFile>java DemoRocks
Sample: #123
Weight: 10.5
Description:
Unclassified
Sample: #234
Weight: 14.9
Description:
Igneous rocks are crystalline solids which
form directly from the cooling of magma.
Sample: #345
Weight: 18.3
Description:
Sedimentary rocks are called secondary, because
they are often the result of the accumulation of small
pieces broken off of pre-existing rocks.
Sample: #456
Weight: 17.1
Description:
Any rock can become a metamorphic rock if the rock
is moved into an environment in which the minerals, which
make up the rock, become unstable and out of equilibrium
with the new environmental conditions.
D:\JavaBatchFile>
Transcribed Image Text:A. Command Prompt D:\JavaBatchFile>javac Rock.java D:\JavaBatchFile>javac IgneousRock.java D:\JavaBatchFile>javac MetamorphicRock.java D:\JavaBatchFile>javac SedimentaryRock.java D:\JavaBatchFile>javac DemoRocks.java D:\JavaBatchFile>java DemoRocks Sample: #123 Weight: 10.5 Description: Unclassified Sample: #234 Weight: 14.9 Description: Igneous rocks are crystalline solids which form directly from the cooling of magma. Sample: #345 Weight: 18.3 Description: Sedimentary rocks are called secondary, because they are often the result of the accumulation of small pieces broken off of pre-existing rocks. Sample: #456 Weight: 17.1 Description: Any rock can become a metamorphic rock if the rock is moved into an environment in which the minerals, which make up the rock, become unstable and out of equilibrium with the new environmental conditions. D:\JavaBatchFile>
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 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