Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this Short Assignment, you will be initiating a class for Atomic Particles. You will be instantiating the following fields: 1 ) The name of
In this Short Assignment, you will be initiating a class for Atomic Particles.
You will be instantiating the following fields:
The name of the atom as a string, "particleName".
The atomic weight of the particle as a double, "particleWeight".
The number of protons as an integer, "protons".
The number of neutrons as an integer, "neutrons".
The speed of the neutron as a double, "particleSpeed".
The xcoordinate of the particle as a double, x
The ycoordinate of the particle as a double, y
The distance from the origin as a double, "magnitude".
The constructor will take each of the fields above as parameters.
You will be instantiating getters and mutators for each of the fields above.
The getters should return the type that the field is The mutators should return void.
Naming should be as follows:
For getters: "get" field name ie "getProtons".
For setters: "set" field name ie "setProtons".
There should be methods in total, including the constructor. All should be public.
You should add one function called "collision" that returns void. It takes in another particle as an input and subtracts the speed of the input particle from the particle it is called from.
You should add another function called "calculateMagnitude" that will find a particle's distance from the origin. Whenever a particle's x and y coordinates are changed, the magnitude should be recalculated and updated. The "calculateMagnitude" function should return a double. Write in C please.
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