ITP4459 assignment 2023 Oct student

Department of Information Technology (Chai Wan) IT524122 HD in Cybersecurity
ITP4459 Advanced Scripting Technology Assignment
Assignment Due Date and Time:
11 Dec 2023 Monday 23:59, through Moodle
This assignment is implementing an Income and Expense Recording System using Object Oriented Programming Techniques. Your coding must be able to show concepts such as Abstraction, Encapsulation, Inheritance, Polymorphism, and Database Connection. Your program must be able to do the following:
1. Establish connection to MySQL database server and perform read/write function.
2. Display income and expense history.
3. Create income and expense records.
Assignment requirements

Add Income Record: The user can add a new income record by choosing a date or using the default date value, filling in the amount and description in the Income label frame, and then clicking the Confirm button to create a new income record in the database.
The new income record would be displayed in the Summary scrolled textbox, and a new record would be created in the database.
Add Expense Record: The user can add a new expense record by choosing a date or using the default date value, filling in the amount and description in the Expense label frame, and then clicking the Confirm button to create a new expense record in the database.
The new expense record would be displayed in the Summary scrolled textbox, and a new record would be created in the database.
CS Help, Email: tutorcs@163.com
Check Monthly History: By choosing both Month and Year, the “Display records” button will be released. The content of both “Select Month” and “Select Year” will be updated whenever a new record is created, the Month option is selected, or the Year option is selected. The value of Month and Year should be obtained from the database.
Click the “Display records” button to check the record for the selected month and year. The record of a specific month-year should be retrieved from the database and displayed properly as shown.
Clear button: All the input records, summary, and selected history options will be cleared. 3

Error Checking: The system should provide input error checking in the following cases:
For income and expense records creation, the amount value should be inputted, positive, and a non- zero value. If not, the following error message will be displayed.
Programming Requirements of the Assignment
var_month: StringVar lst_month: OptionMenu
var_year: StringVar lst_year: OptionMenu
lbf_period: LabelFrame
btn_display_records: Button
btn_in_comfirm: Button
btn_ex_comfirm: Button btn_exit: Button
in_date: tkcalendar.DateEntry
lbf_income: LabelFrame
in_date: tkcalendar.DateEntry
var_in_amount: IntVar ent_in_amount: Entry
lbf_expense: LabelFrame
var_in_desc: StringVar ent_in_desc: Entry
var_ex_desc: StringVar ent_ex_desc: Entry
lbf_summary: LabelFrame
text: scrolledtext.ScrolledText btn_clear: Button
var_ex_amount: IntVar ent_ex_amount: Entry
Layout for Application 4

You are given the above UI layout and a partially developed application class inherited from the Tkinter class for the above requirements. The class diagram of the required library is shown in the next section. You must complete both the application and the class library so that your application produces the same result as the above requirement.
File structure and description of each file Files Classes included
application.py
DisplayHistory IncomeAndExpenseRecordSystem
• A partially developed application that contains the main GUI implemented in the class IncomeAndExpenseRecordSystem(tkinte r.Tk). You must study the code and complete the rest of the program logic.
• You need to add another class (DisplayHistory) in this file to design UI related to displaying monthly history records.
• File used to perform database connection and operations.
• This file contains all methods to retrieve data from the database and inert record to the database
library.py
Record Income_Record Expense_Record
• Supplier classes (i.e. Record, Income_Record, Expense_Record) should be implemented in this file

Things to do
This assignment is divided into two parts: Database and Tkinter GUI.
Study the provided code in each python file and all the comments.
TODO comments are included for easy identification of the parts that need to be completed by you. Part 1 – Database and supplier classes
(a) Complete the code segments in the file db.py. Refer to Database Design for the necessary information.
(b) Completed three supplier classes in the file library.py.
Part 2 – Tkinter GUI
(a) CompletethecodesegmentsofDisplayHistoryclassandIncomeAndExpenseRecordSystem class.
Programming Help, Add QQ: 749389476
Description of Class Library
TYPE = {“I”:”Income”, “E”:”Expense”} __date: datetime.date
__amount: int
__desc: string
__init__(self, date, amount, desc) __str__(self)
save_record(self)
get_date(self)
get_amount(self)
get_desc(self)
get_month(self)
get_year(self) get_existing_months(year=none) get_existing_years(month=none) get_type(self)
execute_query(query) create_table() read_income(month, year) read_expense(month, year) select_month(year=none) select_year(month=none) insert_record(record)
Income_Record
__type: string
__init__(self, date, amount, desc) __str__(self)
get_type(self)
Income_Record
__type: string
__init__(self, date, amount, desc) __str__(self)
get_type(self)
(a) CreateanabstractclassRecordthathas: Attributes:
• __amount
• __init__
• save_record
• get_date
• get_amount
• get_desc
a non-public string to store the date of an income or expense record
a non-public string to store the income or expense amount of a record a non-public dictionary to store the remarks of a record
a dictionary to store the strings that distinguish between different record types
initialize the date, amount, and desc attributes.
call save_record to save a record in the database when a Record object is created
returns the output string of a record as shown in the sample output (e.g., [2023-10-20]: $20 #Lunch#)
a method to insert a new record to the database by calling the method in db.py
returns date for a record
returns amount for a record returns description for a record

• get_month
• get_year
• get_existing_months
• get_existing_years
• get_type
return the month name (e.g., October) using the date value
return the year (e.g., 2023) using the date value
a static method to retrieve a list of months with existing records in the database. If the month variable is received, include the month in the where clause in the select query.
a static method to retrieve a list of years with existing records in the database. If the month variable is received, include the month in the where clause in the select query.
an abstract method used to force all child classes to implement this method. Since the type cannot be determined without more details given.
(b) Create a class Income_Record inherits from class Record that has: Attributes:
• __type Methods:
• __init__
a non-public string to store the type of record
initialize the type attribute
super method call is used to call the parent class __init__ method to initialize the name attributes.
return the output string of a record by adding the record type heading super method call is used to call the parent class __str__ method to output the record details.
Return type for a record
• get_type
(c) Create a class Expense_Record inherits from class Record that has:
Attributes:
• __type Methods:
• __init__
a non-public string to store the type of record
initialize the type attribute
super method call is used to call the parent class __init__ method to initialize the name attributes.
return the output string of a record by adding the record type heading. super method calls to call the parent class __str__ method to output the record details.
Return type for a record
• get_type
(d) CreateaclassConnectDBthathas:
• execute_query
• create_table
• read_income
• read_expense
establish database connection using mysql.connector library to connect database “in_ex_record_system”
create a cursor and use the cursor to execute the received query variable and return the fetched result
create a table “record” with the required column (refer to Database Design section)
return income records of specific month and year from the database
return expense records of specific month and year from the database 8

• select_month
• select_year
• insert_record
return a list of months that have existing records in the database return a list of years that have existing records in the database
Insert a new income or expense record into database, providing all detailed information
Apart from the above specification, you must complete the methods in the Tkinter-related classes, DisplayHistory and IncomeAndExpenseRecordSystem in application.py.
Instructions to students
This is an End-of-Module Assessment and the weighting of this assignment is 20% of the Module Mark.
This assignment should be done by each student individually. Plagiarism will be treated seriously. All assignments that have been found involved wholly or partly in plagiarism (no matter these assignments are from the original authors or from the plagiarists) will score ZERO mark.
You must use Python 3.9 or above the develop the program.
Your source code must follow the coding standard stated in PEP 8 – Style Guide for Python
Code. Marks may be deducted if the coding standard is not followed. You are required to hand in the following:
5.1 A test plan showing the evidence of testing.
5.2 Source code for the entire program, with adequate comments.
Test Case Name Procedure Expected Output Result
Add income record
1. In the income label frame, input the date, amount, and description
2. Click “Confirm” button
A new record should be added to the database.
The corresponding output message is displayed in the summary section.
The month and year option in check for the history label frame is updated accordingly
Pass / Fail
Input an empty amount
1. In the income label frame, leave the amount blank
2. Click “Confirm” button
An error message box “Amount cannot be empty or zero or negative!” should be prompted out.
Pass / Fail
Submit all your works in a single ZIP file under the name of your student ID and name (e.g., 22XXXXXXX-ChanDaiMan.zip) to Moodle before the assignment deadline. Marks will be deducted for late submissions (e.g., during program demonstration) or even score ZERO mark.
Code Help, Add WeChat: cstutorcs
Mark Distribution
• System Implementation (75%)
Part 1 – Database and supplier classes
library.py class Record 15% class Income_Record
class Expense_Record
Part 2 – Tkinter GUI
application.py class DisplayHistory 60% class IncomeAndExpenseRecordSystem
Implementation
Marks Distribution
read_income read_expense select_month select_year insert_record
• Programming Style (10%)
• Test Plan (15%)
Database Design
Table – record
description record_type
VARCHAR(10) VARCHAR(10) VARCHAR(20) DOUBLE
VARCHAR(100) VARCHAR(7)
NOT NULL AUTO_INCREMENT
NOT NULL NOT NULL NOT NULL NOT NULL
NOT NULL NOT NULL