100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Tentamen (uitwerkingen)

COS3711 Assignment 2 2023

Beoordeling
1,7
(3)
Verkocht
19
Pagina's
20
Cijfer
A+
Geüpload op
07-07-2023
Geschreven in
2022/2023

COS assignment 2 solutions with source code and link to the zipped file. Use the document as a reference do not submit it as it is. All the code is running with no errors. 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.

Meer zien Lees minder
Instelling
Vak










Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
7 juli 2023
Bestand laatst geupdate op
10 juli 2023
Aantal pagina's
20
Geschreven in
2022/2023
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

Voorbeeld van de inhoud

For Assistance with other modules
Call or Whatsapp +27682021794
www.myassignments.co.za




COS3711
Assignment 02
2023

Due date
20 July 2023 ,
11:00 PM
Unique Number:732808


There is a link to download the zipped file at the end of the
document.Please DO NOT submit that zipped file as it is, use
it as reference to correct your code and see what needs to be
done. All programs are running correctly with the instruction
on the questions, no errors when building the code, check the
images.

,QUESTION 1
// COUNT.H
#ifndef COUNT_H
#define COUNT_H

#include <QStringList>

class Count
{
public:
Count();
Count(QStringList args);
QString doCount();
private:
bool aFlag, bFlag, cFlag, dFlag;
QStringList filenames;
QString processFile(QString f);
QString process(char flag, QString contents);
};

#endif // COUNT_H


// COUNT.CPP
#include "count.h"
#include <QRegularExpression>
#include <QFile>
#include <QTextStream>

Count::Count()
{
aFlag = false;
bFlag = false;
cFlag = false;
dFlag = false;
}

Count::Count(QStringList args)
{
aFlag = false;
bFlag = false;
cFlag = false;
dFlag = false;

foreach (QString s, args)
{
if (s.at(0) == '-')
{
s.remove(0, 1); //remove -
while (s.length()>0)
{
switch (s.at(0).toLatin1())
{
case 'a': aFlag = true; break;
case 'b': bFlag = true; break;
case 'c': cFlag = true; break;
case 'd': dFlag = true;
}
s.remove(0, 1);
}

, }
else
filenames.append(s);
}

if (!aFlag && !bFlag && !cFlag && !dFlag) // no flags passed
{
aFlag = true;
bFlag = true;
cFlag = true;
dFlag = true;
}
}

QString Count::doCount()
{
QString result;
if (filenames.size() > 0)
{
foreach (QString filename, filenames)
{
result.append(processFile(filename));
result.append("\n");
}
}
else
result = QString("No files to process");
return result;
}

QString Count::processFile(QString f)
{
QString result;

QFile file(f);
if (!file.open(QIODevice::ReadOnly))
{
result = QString("%1 did not open sucessfully").arg(f);
}
else
{
QTextStream in(&file);
QString contents = in.readAll();
file.close();

result.append(QString("***" + f + "***\n"));
QString str = contents.trimmed();
QRegExp rem("[.,?!;:]");
str.remove(rem);

if (aFlag) result.append(process('a', str));
if (bFlag) result.append(process('b', str));
if (cFlag) result.append(process('c', str));
if (dFlag) result.append(process('d', str));
}

return result;
}

QString Count::process(char flag, QString contents)
{
€10,45
Krijg toegang tot het volledige document:
Gekocht door 19 studenten

100% tevredenheidsgarantie
Direct beschikbaar na je betaling
Lees online óf als PDF
Geen vaste maandelijkse kosten

Beoordelingen van geverifieerde kopers

Alle 3 reviews worden weergegeven
2 jaar geleden

Q2 GUI different from assignment.

2 jaar geleden

Buggy Code !!

2 jaar geleden

the CMAKE links dont actually contain CMAKE code but just identical code to the QMake link. This code is very outdated and now wrong, cos3711 has not used QRegExp for several years and qt6 (which is what cos3711 has used for 3 years) no longer supports it, this is definetly not a 2023 assignment but just an older assignment. Very unsatisfied.

2 jaar geleden

Good day, CMake link has been updated. The code is not wrong just using Qt5 that's why at the end of the document it clearly states that it's for educational purposes. The other link is now showing the CMake file sorry about that. Please next time at least notify us on our contact details if you have any other issues with the link.

2 jaar geleden

I did try to phone first and it went straight to voicemail :/ thank you for fixing it though.

1,7

3 beoordelingen

5
0
4
0
3
1
2
0
1
2
Betrouwbare reviews op Stuvia

Alle beoordelingen zijn geschreven door echte Stuvia-gebruikers na geverifieerde aankopen.

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
MyAssignments My Assignments
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
171
Lid sinds
4 jaar
Aantal volgers
144
Documenten
38
Laatst verkocht
4 maanden geleden
My Assignments

3,8

21 beoordelingen

5
11
4
3
3
2
2
1
1
4

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen