100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Other

COS assignment 2

Rating
3.0
(1)
Sold
18
Pages
25
Uploaded on
06-07-2023
Written in
2022/2023

COS assignment 2 solutions with source code and link to the zipped file of the solution at the end of the file change the code wisely. The link is working when not opening ask for help

Institution
Course










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
July 6, 2023
Number of pages
25
Written in
2022/2023
Type
Other
Person
Unknown

Subjects

Content preview

COS3711 2023 ASSIGNMENT 2
SOLUTION
THERE IS A LINK TO THE ZIPPED FILE AT THE END OF THIS DOCUMENT



Crystal Indigo!
Crystal Indigo!
Providing all solutions you need anytime
+27 76 626 8187




**NOTE: if the GUI is displaying differently from what you desire just change
how the widgets are displayed. copy the code and run DO necessary
changes.

,//QUESTION 1
//output




//TextCounter.h
#ifndef TEXTCOUNTER_H
#define TEXTCOUNTER_H

#include <QObject>
#include <QString>
#include <QVector>
class TextCounter : public QObject
{
Q_OBJECT
public:
explicit TextCounter(QObject *parent = nullptr);
void processArguments(int argc, char *argv[]);

private:
bool flagA;
bool flagB;
bool flagC;
bool flagD;

void countOccurrences(const QString &filename);
void printResults(int wordCount, int hyphenatedCount, int
sameCharacterCount, int nonVowelStartCount);
QString removePunctuation(const QString &text) const;
bool isWordLongerThan4CharsStartingWithCapital(const QString &word);
bool isHyphenatedWord(const QString &word);
bool isSameCharacterWord(const QString &word);
bool doesNotStartWithVowel(const QString &word);



};

#endif // TEXTCOUNTER_H



//TextCounter.cpp
#include "textcounter.h"
#include <QDebug>

, #include <QFile>
#include <QTextStream>
#include <QRegularExpression>

TextCounter::TextCounter(QObject *parent) : QObject(parent),
flagA(false), flagB(false), flagC(false), flagD(false)
{
}

void TextCounter::processArguments(int argc, char *argv[])
{
// If no arguments provided, print a message
if (argc == 1) {
qDebug() << "No arguments provided. Please include file name(s).";
return;
}

// Parse the arguments
QVector<QString> filenames;
for (int i = 1; i < argc; ++i) {
QString arg = QString::fromUtf8(argv[i]);
if (arg.startsWith('-')) {
if (arg.contains('a'))
flagA = true;
if (arg.contains('b'))
flagB = true;
if (arg.contains('c'))
flagC = true;
if (arg.contains('d'))
flagD = true;
} else {
filenames.append(arg);
}
}

// If no flags provided, assume all flags were used
if (!flagA && !flagB && !flagC && !flagD) {
flagA = true;
flagB = true;
flagC = true;
flagD = true;
}

// Process each file
for (const QString &filename : filenames) {
countOccurrences(filename);
}
}

void TextCounter::countOccurrences(const QString &filename)
{

Reviews from verified buyers

Showing all reviews
2 year ago

waste of money those codes not running and link not accessible for the zipped files

2 year ago

If you did everything right your applications should run and also link should open, because the code and link have been tested by a lot of people and no complaints. If you need assistance contact on whatsapp for help

3.0

1 reviews

5
0
4
0
3
1
2
0
1
0
Trustworthy reviews on Stuvia

All reviews are made by real Stuvia users after verified purchases.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
CrystalIndigo University of South Africa (Unisa)
Follow You need to be logged in order to follow users or courses
Sold
486
Member since
5 year
Number of followers
226
Documents
73
Last sold
1 month ago
CrystalIndigo Solutions

providing all solutions to all computer science modules

4.1

51 reviews

5
27
4
13
3
6
2
1
1
4

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions