javadocstool.
Sir Richard Branson, owner of Virgin Galactic, is VERY interested in space travel. He is teaming up with quite a few companies to make a spacecraft that will carry humans to space, but he knows there are several other companies that are trying to do that as well. He wants to beat Bezos and Musk so he can be first at something, and has set his sights on being the first company to offer round-trip rides to the planet Neptune, some 4.4 Billion Kilometers away from Earth. The round-trip will thus be over 8.8 Billion Km. However, to save costs, Branson has decided on instruments that can only measure meters, not Kilometers, so that means the distance will be some 8.8 Trillion meters.
Another factor is the amount of time it will take. If we can travel at the speed of light, which is some
299,792,458 meters/second, we can get there in a mere 8.15 hours. However, since travel and that speed
isn't possible, and since we can't instantaneously jump to light speed
, we will have to make do
by ramping up linearly to half the speed of light for the trip, then decelerate when we get there, and
reverse that process on the way back.
For this homework, you will develop public class BrobdingnagianInt,
[also known as BrobInt
], whose objects model arbitrarily-large integers. Basically, you are
being tasked with re-inventing some of the material of java.Math.BigInteger to accomplish
the following activities.
Don't forget to javadoc your code…
Ground Rules
BrobdingnagianInt class.thisrefers to an instantiated object of your BrobdingnagianInt class.
BrobdingnagianInt as
BrobInt which will be much easier to type. You will be typing this over and over
and over and over, so it is best if you get used to the shorter name from the start.public BrobInt( String value )public BrobInt add( BrobInt value )public BrobInt subtract( BrobInt value )public BrobInt multiply( BrobInt value )public BrobInt divide( BrobInt value )public BrobInt remainder( BrobInt value )public String toString()public int compareTo( BrobInt value )public boolean equals( Object x )public static BrobInt valueOf( long value )public static final BrobInt ZEROpublic static final BrobInt ONEpublic static final BrobInt TENTest Driven Development [TDD]you must first construct unit tests for the above items before coding the methods themselves. Use the
main() method of your class to invoke these unit tests. [In other words, the command
java BrobIntTester will run your unit tests.] Try using Java's assert statement
in the tests you write; or even better, use JUnit.UnsupportedOperationException.Neptune.java
which will help Sir Richard achieve his goal. Your program will take one command line argument, which
is the acceleration factor for the trip. Your program with then use that number to speed the
spacecraft up to 1/2 the speed of light from a starting speed of 11,186 meters/second [the escape
velocity of Earth], and slow it down again in time to reach Neptune at a speed of 23,500 meters/second.
We then need to reverse the calculation to get back to Earth.Notes and Suggestions:
can of worms!
BrobInt.java file containing the
methods listed above, as well as any other helper methods or extra things you may want
to implementBrobIntTester.java file containing
your tests, which may end up in your mainprogram of your BrobInt.java file, but it is highly recommended that this be a separate file
Neptune.java program file in which you implement your BrobInt to simulate
a flight to the planet Neptune and backreal world.
chunificationand
Russian Peasant Multiplication [RPM]
Submission Guidelines: Make a sub-directory in your repository as mentioned above,
called homework06
and commit your source code into it. DON'T FORGET TO ADD A COMMIT COMMENT!