Question: JAVA 1. Your task for this lab is to create an ADT for the elements in the periodic table. You will create an abstract class

JAVA

JAVA 1. Your task for this lab is to create an ADT

1. Your task for this lab is to create an ADT for the elements in the periodic table. You will create an abstract class called "Elements". Then, you will add 2 different sub-classes, which will represent the 2 types of elements in the periodic table: "Metals and Nonmetals. All types have 3 common attributes; energy_level (int), symbol (string) and weight (double). Please do not forget to hide them properly. a. Provide appropriate constructors (Hint: perform code reuse by using super). b. Provide toString operation that returns the format given in the example. Ex: Nonmetal 1 H 1.008 C. Write a main, where you declare 4 elements (2 from each type) with their proper information. Then, print them on the screen to test your toString implementation. Note: You can get the necessary information from: ptable.com 2. For second task you will write a function (not a class method) that takes a list of elements as parameter and returns nothing. Function will check whether the elements in the list can create compounds or not. There are 3 types of compounds and rules to create them can be found below. Rules for creating a compound: a. Any number of metals can create an "alloy". b. A metal and any number of nonmetals can create "ionic compounds or salts" C. Any number of nonmetals together can create "molecular compounds" If your list parameter includes a group that fits the rules above, your function should print which type of compound they may create. Lastly, add exception handling to your function. If the given list includes elements that does not fit any of the rules above, the function will throw an exception. Create a user defined exception class and handle it. Test this function in your main by sending 2 different list of elements from combinations of 4 elements you have created 1. Your task for this lab is to create an ADT for the elements in the periodic table. You will create an abstract class called "Elements". Then, you will add 2 different sub-classes, which will represent the 2 types of elements in the periodic table: "Metals and Nonmetals. All types have 3 common attributes; energy_level (int), symbol (string) and weight (double). Please do not forget to hide them properly. a. Provide appropriate constructors (Hint: perform code reuse by using super). b. Provide toString operation that returns the format given in the example. Ex: Nonmetal 1 H 1.008 C. Write a main, where you declare 4 elements (2 from each type) with their proper information. Then, print them on the screen to test your toString implementation. Note: You can get the necessary information from: ptable.com 2. For second task you will write a function (not a class method) that takes a list of elements as parameter and returns nothing. Function will check whether the elements in the list can create compounds or not. There are 3 types of compounds and rules to create them can be found below. Rules for creating a compound: a. Any number of metals can create an "alloy". b. A metal and any number of nonmetals can create "ionic compounds or salts" C. Any number of nonmetals together can create "molecular compounds" If your list parameter includes a group that fits the rules above, your function should print which type of compound they may create. Lastly, add exception handling to your function. If the given list includes elements that does not fit any of the rules above, the function will throw an exception. Create a user defined exception class and handle it. Test this function in your main by sending 2 different list of elements from combinations of 4 elements you have created

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!