100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4.2 TrustPilot
logo-home
Examen

COS3711 Assignment 2 2023

Puntuación
1,7
(3)
Vendido
19
Páginas
20
Grado
A+
Subido en
07-07-2023
Escrito en
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.

Mostrar más Leer menos
Institución
Grado










Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
Grado

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

Temas

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)
{
10,57 €
Accede al documento completo:
Comprado por 19 estudiantes

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Reseñas de compradores verificados

Se muestran los 3 comentarios
2 año hace

Q2 GUI different from assignment.

2 año hace

Buggy Code !!

2 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.

2 año hace

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 año hace

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

1,7

3 reseñas

5
0
4
0
3
1
2
0
1
2
Reseñas confiables sobre Stuvia

Todas las reseñas las realizan usuarios reales de Stuvia después de compras verificadas.

Conoce al vendedor

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 My Assignments
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
171
Miembro desde
4 año
Número de seguidores
144
Documentos
38
Última venta
5 meses hace
My Assignments

3,8

21 reseñas

5
11
4
3
3
2
2
1
1
4

Recientemente visto por ti

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