COS2614 EXAM
PACK 2024
QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:
, lOMoARcPSD|31863004
COS2614 October/November 2014
1 Question 1
1.1 Complete Main for Input Age
MainFunction
QString userInput = QInputDialog::getText(0,”DOB”,”Enter Date of Birth (Format dd/mm/yyyy)”);
QStringList strDOB = QString.split(“/”);
QList<int> IntDOB;
For (int I = 0; I < strDOB.size(); i++)
{
IntDOB.append(strDOB[i].toInt());
}
Int userAge = computerAge(IntDOB[0]/intDOB[1]/intDOB[2]));
QMessageBox::Information(0,”Your Age”, userAge);
1.2 DateList manages a list of QDate. Explain three different ways of designing such a class.
1) class DateList : public QList;
2) You can create a QList<QDates> as a member function.
3) You can have a DateList class which has *QDate objects
#include QDate
#include QList
#include
Page 1 of 8
, lOMoARcPSD|31863004
COS2614 October/November 2014
1.3 Draw a UML representation of the relationship between QDate and DateList where QDate
instances exist after a DateList Instance has been destroyed.
QList
DateList Date
#Date d; #date QDate
1.4 Name the widget class in QT framework that is only used to input a date
QCalendarWidget
Page 2 of 8
Downloaded by Gabriel Musyoka ()
, lOMoARcPSD|31863004
COS2614 October/November 2014
2 UML Diagram
2.1 Virtual double pay() = 0;
2.2 You cannot instantiate a pure virtual function
2.3 Hourly::Hourly(double hr) : Payment(“Hourly”){
HourlyRate = hr;
Hours = 0.0;
}
Page 3 of 8
Downloaded by Gabriel Musyoka ()
PACK 2024
QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:
, lOMoARcPSD|31863004
COS2614 October/November 2014
1 Question 1
1.1 Complete Main for Input Age
MainFunction
QString userInput = QInputDialog::getText(0,”DOB”,”Enter Date of Birth (Format dd/mm/yyyy)”);
QStringList strDOB = QString.split(“/”);
QList<int> IntDOB;
For (int I = 0; I < strDOB.size(); i++)
{
IntDOB.append(strDOB[i].toInt());
}
Int userAge = computerAge(IntDOB[0]/intDOB[1]/intDOB[2]));
QMessageBox::Information(0,”Your Age”, userAge);
1.2 DateList manages a list of QDate. Explain three different ways of designing such a class.
1) class DateList : public QList;
2) You can create a QList<QDates> as a member function.
3) You can have a DateList class which has *QDate objects
#include QDate
#include QList
#include
Page 1 of 8
, lOMoARcPSD|31863004
COS2614 October/November 2014
1.3 Draw a UML representation of the relationship between QDate and DateList where QDate
instances exist after a DateList Instance has been destroyed.
QList
DateList Date
#Date d; #date QDate
1.4 Name the widget class in QT framework that is only used to input a date
QCalendarWidget
Page 2 of 8
Downloaded by Gabriel Musyoka ()
, lOMoARcPSD|31863004
COS2614 October/November 2014
2 UML Diagram
2.1 Virtual double pay() = 0;
2.2 You cannot instantiate a pure virtual function
2.3 Hourly::Hourly(double hr) : Payment(“Hourly”){
HourlyRate = hr;
Hours = 0.0;
}
Page 3 of 8
Downloaded by Gabriel Musyoka ()