GitHub Repository link: https://github.com/jessehartloff/AO3
The starter code defines each method and class that will be used during testing, and you should only use these classes/methods in your tests.
Test and implement the constructor and netGains
methods in the
money.DebtCalculator
class.
Test the following features of your money.DebtCalculator
class:
String
for a parameter. This will be a CSV file
where
each line is in the format "person1,person2,amount" meaning the person1 owes person2 the amount
of dollars. All dollar values will be integers (Whole dollar amounts only). If a line is
"Paul,Jesse,50" then Paul owes Jesse $50. The constructor will read this file and store all
the debt information in instance variables. All CSV files should be in a directory named
data
netGains
that takes the name of a person as a String
and
returns the net gains
for that person. This is the total amount that person will have gained after all debts are
settled. Net gains can be negative. For example, if Paul owes Jesse $50 and Jesse owes Leo $75,
then Jesse's net gains are -$25 and the method should return -25 as an int.
Implement the tested functionality.
Test and implement the findCycle
method in the money.DebtCalculator
class.
Test the following feature of your money.DebtCalculator
class:
findCycle
method that takes no parameters and returns a reference to a
Cycle
object using
the provided Cycle
class. This method will detect if there is a cycle in the debt data and
will return it if it exists. A cycle exists if there's any number of people all of whom owe
money to the next person in a way the eventually returns to the original debtor. The amount of
the cycle is the minimum amount owed throughout the cycle. If such a cycle exists, the amount of
each debt in the cycle could be reduced by the cycle amount (You don't have to reduce the debts,
just detect the cycle). For example, if Paul owes Jesse $50, Jesse owes Leo $75, and Leo owes
Paul $100, there is a cycle [Paul, Jesse, Leo] of $50
null
Cycle
object containing the names of everyone in the cycle in
the
order in which they appear, and the cycle amount. Note that the starting point is ambiguous so
your tests must accept any valid ordering. In the example above, there are three valid orderings
[Paul, Jesse, Leo], [Jesse, Leo, Paul], and [Leo, Paul, Jesse]
Implement the findCycle
method.