,COS3711 Assignment 1 (COMPLETE ANSWERS) semester
1 2025 - DUE April 2025; 100% trusted, comprehensive and
complete reliable solution with clear explanation
Table of Contents
1. Introduction
o Overview of the Calculator Application
o Design Patterns Implemented (Factory Method,
Singleton)
2. Class Hierarchy for Mathematical Operations
o Operation Class
Abstract Method compute()
o Concrete Operation Classes
AddOperation
SubOperation
MulOperation
DivOperation
3. OperationFactory Class (Singleton)
o Singleton Design Pattern
o Method: create_operation()
4. Calculator GUI Implementation
o GUI Components
QDoubleSpinBox for Input
QPushButton for Operations (+, -, *, /, Clear)
QLCDNumber for Display
o Event Handling
Connecting Buttons to Slots
Implementing Slot calculate()
5. Handling Edge Cases and Errors
, o Division by Zero
o Overflow Handling in QLCDNumber
6. Running the Application
o Setting Up the Environment
o Running the Calculator Script
7. Conclusion
o Summary of Features and Design
o Possible Improvements
Question 1 Write a console application that can be run from the
command line using the following forms: count // run without
any parameters count // pass one file name count fileT // pass
more than one file name count –a –b fileT // pass flags to change
behaviour count –ab –c // pass flags in an alternative way If no
arguments are provided, then print a message describing what
arguments should be included. The application should, using
regular expressions, count the number of occurrences of each of
the following in the text files given. • If the –a flag is set, count
the number of words longer than 4 characters that start with a
capital letter. There may be further capital letters in the word. •
If the –b flag is set, count the number of words that are
hyphenated. This hyphen should not be at the start or end of a
word. • If the –c flag is set, count the number of words that start
and end on the same character. • If the –d flag is set, count the
number of words that do not start with a vowel. Note that these
words can start with any character, and do not just have to start
with alphabetic characters. If no flags are provided, it is assumed
that all counts should be performed. It is suggested that you
1 2025 - DUE April 2025; 100% trusted, comprehensive and
complete reliable solution with clear explanation
Table of Contents
1. Introduction
o Overview of the Calculator Application
o Design Patterns Implemented (Factory Method,
Singleton)
2. Class Hierarchy for Mathematical Operations
o Operation Class
Abstract Method compute()
o Concrete Operation Classes
AddOperation
SubOperation
MulOperation
DivOperation
3. OperationFactory Class (Singleton)
o Singleton Design Pattern
o Method: create_operation()
4. Calculator GUI Implementation
o GUI Components
QDoubleSpinBox for Input
QPushButton for Operations (+, -, *, /, Clear)
QLCDNumber for Display
o Event Handling
Connecting Buttons to Slots
Implementing Slot calculate()
5. Handling Edge Cases and Errors
, o Division by Zero
o Overflow Handling in QLCDNumber
6. Running the Application
o Setting Up the Environment
o Running the Calculator Script
7. Conclusion
o Summary of Features and Design
o Possible Improvements
Question 1 Write a console application that can be run from the
command line using the following forms: count // run without
any parameters count // pass one file name count fileT // pass
more than one file name count –a –b fileT // pass flags to change
behaviour count –ab –c // pass flags in an alternative way If no
arguments are provided, then print a message describing what
arguments should be included. The application should, using
regular expressions, count the number of occurrences of each of
the following in the text files given. • If the –a flag is set, count
the number of words longer than 4 characters that start with a
capital letter. There may be further capital letters in the word. •
If the –b flag is set, count the number of words that are
hyphenated. This hyphen should not be at the start or end of a
word. • If the –c flag is set, count the number of words that start
and end on the same character. • If the –d flag is set, count the
number of words that do not start with a vowel. Note that these
words can start with any character, and do not just have to start
with alphabetic characters. If no flags are provided, it is assumed
that all counts should be performed. It is suggested that you