CSE2350 - Object-Oriented So ftware
Engineering
Assessment
[5 marks]
[2 marks]
[2 marks]
[2 marks]
[2 marks]
[5 marks]
[5 marks]
[5 marks]
[5 marks]
[3 marks]
[8 marks]
[3 marks]
[8 marks]
[6 marks]
[8 marks]
[3 marks]
[5 marks]
[4 marks]
[3 marks]
[6 marks]
[6 marks]
[4 marks]
[3 marks]
[5 marks]
[6 marks]
[8 marks]
[2 marks]
[5 marks]
[8 marks]
double max(double a, double b) { return a>b ? a : b; } double max(int a,int b) { return a>b ? a : b; } int main(void) { cout << max(1,2.2); }
[3 marks]
[5 marks]
[6 marks]
[5 marks]
[5 marks]
MyClass mc; cout << mc;to behave identically to the code:
MyClass mc; mc.PrintMeTo(cout);
[8 marks]
class String { public: String(void) : myStr(0) {} String(char* str) { myStr = new char[strlen(str)]; strcpy(myStr,str); } private: char* myStr; };so that the code:
String s ("a string"); s[1] = 'z'; cout << s[1] << endl;correctly allows access to individual characters in the string.
[8 marks]
[4 marks]
[4 marks]
[3 marks]
[3 marks]
[2 marks]
class String { public: String(void) : myStr(0) {} String(char* str) { myStr = new char[strlen(str)]; strcpy(myStr,str); } private: char* myStr; };by adding a suitable destructor.
[5 marks]
[5 marks]
[2 marks]
[5 marks]
void Value::Negate(void) { this->myVal *= -1; }and this one:
void Value::Negate() { myVal = -myVal; }
[3 marks]
[2 marks]
[2 marks]
[8 marks]
[4 marks]
[4 marks]
Score play(void) { Score s; while (!match()) { while (!game()) { s = set(); } } return s; }
[8 marks]
[3 marks]
[5 marks]
[3 marks]
[6 marks]
[4 marks]
[4 marks]
[5 marks]
[6 marks]
[6 marks]
[5 marks]
[5 marks]
[5 marks]
[4 marks]
[4 marks]
[5 marks]
int globalVal = 0; int main(void) { while (globalval<10) { if (globalval < 2) { globalval *= 2; } else if (globalval > 8) { globalval -= 2; } else { globalval = 10-globalval; } } for (int i=0; i<globalval; i++) { cout << i << endl; } }Show all your working.
[8 marks]
int x = 10; do { double y; if (cin >> y) { if (y!=0) { for (i=1; i<y; i++) { cout << i*x/y << endl; } } } } while (x-->0);Show all your working.
[8 marks]
template <class TYPE> TYPE max(TYPE a, TYPE b) { return (a>b) ? a : b; }Show all your working.
[8 marks]
[5 marks]
[10 marks]
[8 marks]
[6 marks]
How does backtracking help in program debugging?
[6 marks]
[5 marks]
[4 marks]
[4 marks]
[8 marks]
[5 marks]
[5 marks]
[4 marks]
[5 marks]
[10 marks]
[6 marks]
[4 marks]
[3 marks]
[8 marks]
[8 marks]
class Base { public: virtual void PrintMe(void) { cout << "Base!" << endl; } }; class Derived { public: virtual void PrintMe(void) { Base::PrintMe(); cout << "Derived!" << endl; } }; int main(void) { Base b; Derived d; // object diagram should be drawn at this point b.PrintMe(); d.PrintMe(); }
[8 marks]
The El Cheapo video store needs a computerized database system to record
borrowed videos, CDs, and video games. Videos are categorized as new release,
weekly, or five-for-five-dollars. video games may be either PlayStation,
MegaDrive, or Saturn.
El Cheapo need to be able to check whether an individual item is currently
on loan, when it is due back, how much is owing on it (if it is overdue),
as well as details of who borrowed it (i.e. name, address, phone number,
licence number).
They also need to be able to generate lists of items selected by various
criteria: item type, items currently in, items currently out, most popular,
least recently borrowed. This lists must be able to be sorted alphabetically
and by video ID number.
They also want to generate lists of customers secting by various criteria:
most prolific borrowers, inactive (no borrowing for a month or more), who
owes the most on overdue books.
[20 marks]
We are creating a symbolic mathematics package. We want to be able
to specify functions of X, Y, and Z. Each function will consist of a left-
and right-hand expression, and each expression will consist of one or more
terms, with addition or subtraction operators between them.
Each term may be either a constant (a numerical value or the special constant
C) or a product (a numerical coefficient followed by one ore more of the variables
X, Y, and Z, each raised to some power).
The mathematics package will be able to perform the following operations on
a function:
[20 marks]
Last updated: September 30, 2005