Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 . 5 Defining your own class ( Atom ) Your task is write a class named Atom. The Atom class has three instance variables

3.5 Defining your own class (Atom)
Your task is write a class named Atom. The Atom class has three instance variables representing an atom's state: the number of protons, neutrons, and electrons. The constructor should look like this:
public Atom(int givenProtons, int givenNeutrons, int givenElectrons){
// insert code to assign given values to instance variables
}
Class Atom should also have the following methods:
int getatomicMass ()- returns total number of protons plus neutrons
int getAtomicCharge ()- returnsthe difference between the number of protons and electrons
void decay ()- decreases the number of protons by 2 and the number of neutrons by 2
In addition to the Atom class, there is a class AtomTest with a main method that will execute when you click the Run button in "Develop mode". The given main method does very little, but you can edit this main method however you wish to try things out, it will not be graded. Note that it won't compile until you have provided the specified constructor.
Note that the editing window has a dropdown menu to switch between the two files Atom.java and AtomTest.java. The code for the class Atom MUST go in the file Atom.java.
When in "Submit mode", the auto-grader will run a number of unit tests. The first one just checks that you have all the declarations right and have not added anything like a public variable that violates the specified public API. Read the error messages starting at the top and be sure you pass this first test before worrying about the rest.
For this exercise, you can resubmit as many times as you want. Only the Atom class is tested and graded when you submit.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago