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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education