Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 3 fuera de 20 páginas
Examen

COS3711 Assignment 2 2023

Document preview thumbnail
Vista previa 3 fuera de 20 páginas

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.

Vista previa del contenido

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)
{

Información del documento

Subido en
7 de julio de 2023
Archivo actualizado en
10 de julio de 2023
Número de páginas
20
Escrito en
2022/2023
Tipo
Examen
Contiene
Preguntas y respuestas
$12.74
Comprado por 19 estudiantes

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
MyAssignments
3.8
(21)
Vendido
176
Seguidores
144
Artículos
42
Última venta
2 semanas hace

Reseñas de compradores verificados

3 año hace

Q2 GUI different from assignment.

3 año hace

Buggy Code !!

3 año hace

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.

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.

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




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes