Question: Hey I have a question related to Object Oriented Programming in JAVA. Here is the description of the peoblem: Last month, scientists at NASA discovered

Hey I have a question related to Object Oriented Programming in JAVA. Here is the description of the peoblem:

Hey I have a question related to Object Oriented Programming in JAVA.

Last month, scientists at NASA discovered life on Mars, Neptune, and Saturn! Your job is to create a program that can convert currencies between the planets to aid in interplanetary transactions. Implementation details You will create 3 currency classes: Mars.java, Neptune.java, and Saturn.java. Each of these classes must derive from an abstract parent class Currency.java and implement the interface Exchangeable.java. Currency.java The currency class must contain the following data members: name of the currency (String currencyName) o Mars Money o NeptuneNuggets Saturn Silver total funds (double totalFunds) Additionally, because the planets only trust Earth, dollars will serve as the intermediary currency. The Currency class will contain the following 2 abstract methods: public abstract double toEarthDollars (double amount); public abstract double fromEarthDollars (double EarthDollars); Use these methods to exchange money between planets. Exchangeable.java Exchange rates should be implemented as constants in the Exchangeable interface. 1.00 Earth Dollar (ED) = 1.30 Mars Money (MM) = 0.87 Saturn Silver (SS) = 2.00 Neptune Nuggets (NN) Note that we may change the values of the exchange rates when testing your code. We will only edit the Exchangeable interface, so rates should be encapsulated in and accessed from Exchangeable.java. Exchangeable must also include a method to exchange between the current currency and a target currency. When a planet calls exchange () with another planet and a specified amount, the methods toEarthDollars () and fromEarthDollars () should be used to convert the source currency into the target currency. The amount should be subtracted from the calling planet and added to the target planet. If a planet tries to exchange more funds than it currently has, an error should be printed and no transfer should occur. The exchange method should have the following signature: public void exchange (Exchangeable other, double amount); The remainder of the implementation details are up to you. As always, use best practices, including the principle of least privilege, inheritance, and encapsulation as much as possible

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!