Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I was given the following: The UML had: Transaction: - m_Description: QString -

ID: 3648210 • Letter: I

Question

I was given the following:

The UML had:

Transaction:
- m_Description: QString
- m_Date: QDate
________________
+ transaction(c: QString, d: QDate)
+ toString(): QString
+getDate():QDate
__________________

"The class Transactions represents a transaction in an account and it has two data members to represent the type of transaction (exaplres are account opened, deposit and withdrawal) and the date on which the transaction occured. the constructor of this class takes the type and date as input parameters. The toString () function returns a string comprising the two data members, formatted in a readable way. The getDate() function returns the date of the transaction"


So far I have this:

class Transaction
{
private:
QString m_Description;
QDate m_Date (QDate::currentDate());
public:
Transaction(QString c, QString d);
QString toString();
QDate getDate();
};

and then i have:

Transaction::Transaction(QString c, QString d)
{
m_Description = c;
m_Date = d;
}

QString Transaction::toString()
{
//opened
//deposit
//withdrawel
}

QDate Transaction::getDate()
{
(QDate::currentDate());
}

How would you rewrite this piece of code to work properly? And how do you call it in the main part of your program? :)


Explanation / Answer

#include "transaction.h"Transaction::Transaction(){ m_date = QDate::currentDate(); m_time = QTime::currentTime();}Transaction::Transaction(int id){ m_ID = id; m_date = QDate::currentDate(); m_time = QTime::currentTime();}Transaction::Transaction(int id, int accountID, float amount, QString description, QString category){ m_ID = id; m_accountID = accountID; m_amount = amount; m_description = description; m_category = category; m_date = QDate::currentDate(); m_time = QTime::currentTime();} int Transaction::ID() { return m_ID; } int Transaction::accountID() { return m_accountID; } float Transaction::amount() { return m_amount; } QDate Transaction::date() { return m_date; } QTime Transaction::time() { return m_time; } QString Transaction::description() { return m_description; } QString Transaction::category() { return m_category; } void Transaction::setAccountID(int accountID) { m_accountID = accountID; } void Transaction::setAmount(float newAmount) { m_amount = newAmount; } void Transaction::setDescription(QString description) { m_description = description; } void Transaction::setCategory(QString category) { m_category = category; } Is it OK?

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote