COS3711
ASSIGNMENT 2 2025
UNIQUE NO.
DUE DATE: 18 JULY 2025
,Advanced Programming
1. Store Application Structure
Classes to Design
A. Customer
class Customer {
QString name;
QList<Transaction*> transactions;
};
B. Item
enum class ItemType { Book, Magazine };
class Item {
QString name;
ItemType type;
};
C. Transaction
class Transaction {
QDateTime dateTime;
QList<Item*> items;
QList<int> quantities; // matching index
};
D. Store
class Store {
QList<Customer*> customers;
QList<Item*> items;
QList<Item*> itemBackup;
void backupItems();
void restoreItems();
};
�GUI Features (MainWindow)
Menus:
o File → Exit
o Customer → Add Customer
o Item → Add Item, Restore Items
o Transactions → New Transaction
o Broadcast → Send Transactions
Toolbar:
o Quick buttons for the actions above
Status Bar:
, o Feedback on operations (e.g., "Item added", "Transaction recorded")
Tree View:
o QTreeView to display customers and their transactions using a
QStandardItemModel.
Input Dialogs:
o QInputDialog for customer and item names
o QComboBox, QSpinBox in a QDialog for transactions
💾 Memory & GUI Management
Manually create widgets using parent-child structure
Use delete or smart pointers to manage memory (especially transactions/items)
Use setFocus(), setTabOrder(), and manage widget states (enable/disable)
Provide feedback via QMessageBox and status bar
2. UDP Broadcasting
Create a QThread subclass for broadcasting
Format all transactions as XML (QDomDocument)
Use QUdpSocket to broadcast on a known port
Example XML:
<store>
<customer name="John Doe">
<transaction date="2025-07-01T12:34">
<item name="Intro to Qt" type="Book" quantity="1"/>
</transaction>
</customer>
</store>
3. 📥 UDP Receiver Application
Simple Qt GUI with a QTextEdit
Use QUdpSocket to listen on the same port
ASSIGNMENT 2 2025
UNIQUE NO.
DUE DATE: 18 JULY 2025
,Advanced Programming
1. Store Application Structure
Classes to Design
A. Customer
class Customer {
QString name;
QList<Transaction*> transactions;
};
B. Item
enum class ItemType { Book, Magazine };
class Item {
QString name;
ItemType type;
};
C. Transaction
class Transaction {
QDateTime dateTime;
QList<Item*> items;
QList<int> quantities; // matching index
};
D. Store
class Store {
QList<Customer*> customers;
QList<Item*> items;
QList<Item*> itemBackup;
void backupItems();
void restoreItems();
};
�GUI Features (MainWindow)
Menus:
o File → Exit
o Customer → Add Customer
o Item → Add Item, Restore Items
o Transactions → New Transaction
o Broadcast → Send Transactions
Toolbar:
o Quick buttons for the actions above
Status Bar:
, o Feedback on operations (e.g., "Item added", "Transaction recorded")
Tree View:
o QTreeView to display customers and their transactions using a
QStandardItemModel.
Input Dialogs:
o QInputDialog for customer and item names
o QComboBox, QSpinBox in a QDialog for transactions
💾 Memory & GUI Management
Manually create widgets using parent-child structure
Use delete or smart pointers to manage memory (especially transactions/items)
Use setFocus(), setTabOrder(), and manage widget states (enable/disable)
Provide feedback via QMessageBox and status bar
2. UDP Broadcasting
Create a QThread subclass for broadcasting
Format all transactions as XML (QDomDocument)
Use QUdpSocket to broadcast on a known port
Example XML:
<store>
<customer name="John Doe">
<transaction date="2025-07-01T12:34">
<item name="Intro to Qt" type="Book" quantity="1"/>
</transaction>
</customer>
</store>
3. 📥 UDP Receiver Application
Simple Qt GUI with a QTextEdit
Use QUdpSocket to listen on the same port