Answered step by step
Verified Expert Solution
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
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 Atomint 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 and the number of neutrons by
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 autograder 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started