Package makingtransactions
Class Transaction
java.lang.Object
makingtransactions.Transaction
A class for creating transactions.
-
Constructor Summary
ConstructorsConstructorDescriptionTransaction
(String transactionName) Create a transaction without any credit and debit.Transaction
(String transactionName, double debit, double credit) Create a transaction with credit and debit. -
Method Summary
Modifier and TypeMethodDescriptiondouble
Get the crebit (How much money should be spent) for the transaction.double
getDebit()
Get the debit (How much money should be earned) for the transaction.Get the name of the transaction.void
setCredit
(double credit) Set the credit (How much money should be spent) for the transaction.void
setDebit
(double debit) Set the debit (How much money should be earned) for the transaction.void
setTransactionName
(String transactionName) Set the name of the transaction.toString()
-
Constructor Details
-
Transaction
Create a transaction with credit and debit.- Parameters:
transactionName
- The name of the transaction.debit
- How much money should be earned.credit
- How much money should be spent.
-
Transaction
Create a transaction without any credit and debit.- Parameters:
transactionName
- The name of the transaction.
-
-
Method Details
-
getTransactionName
Get the name of the transaction.- Returns:
- The name of the transaction.
-
setTransactionName
Set the name of the transaction.- Parameters:
transactionName
- The name of the transaction.
-
getDebit
public double getDebit()Get the debit (How much money should be earned) for the transaction.- Returns:
- The debit for the transaction.
-
setDebit
Set the debit (How much money should be earned) for the transaction.- Parameters:
debit
- The debit applied to the transaction.- Throws:
IllegalArgumentException
- If the debit is a negative number.
-
getCredit
public double getCredit()Get the crebit (How much money should be spent) for the transaction.- Returns:
- The credit for the transaction.
-
setCredit
Set the credit (How much money should be spent) for the transaction.- Parameters:
credit
- The credit applied to the transaction.- Throws:
IllegalArgumentException
- If the crebit is a negative number.
-
toString
-