Package makingtransactions
Class Transaction
java.lang.Object
makingtransactions.Transaction
A class for creating transactions.
-
Constructor Summary
ConstructorsConstructorDescriptionTransaction(String transactionName, int transactionId) Create a transaction without any credit and debit.Transaction(String transactionName, int transactionId, double debit, double credit) Create a transaction with credit and debit. -
Method Summary
Modifier and TypeMethodDescriptiondoubleGet the crebit (How much money should be spent) for the transaction.doublegetDebit()Get the debit (How much money should be earned) for the transaction.intGet the ID of the transaction.Get the name of the transaction.voidsetCredit(double credit) Set the credit (How much money should be spent) for the transaction.voidsetDebit(double debit) Set the debit (How much money should be earned) for the transaction.voidsetTransactionId(int transactionId) Set the name of the transaction.voidsetTransactionName(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.transactionId- The ID 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.transactionId- The ID 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.
-
setTransactionId
public void setTransactionId(int transactionId) Set the name of the transaction.- Parameters:
transactionId-
-
getTransactionId
public int getTransactionId()Get the ID of the transaction.- Returns:
-
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
-