Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; class Slacker :public Comparable{ string name; int classesMissed; public: Slacker(int missed, string n): classesMissed(missed), name(n) {} // they don't even

#include #include using namespace std;

class Slacker :public Comparable{ string name; int classesMissed; public: Slacker(int missed, string n): classesMissed(missed), name(n) {} // they don't even bother to validate their input! string toString() const { return name + " missed " + to_string(classesMissed) + " classes"; } };

class Workaholic:public Comparable { int workHours; // they don't have a name ... work is more important! public: Workaholic(int wh) { assert(wh > 12 && wh

};

class WorkFamilyBalanced:public Comparable { string name; int familyHours; int workHours; public: WorkFamilyBalanced(int fh, int wh, string n): name(n) { assert(fh >= 0 && wh >= 0); familyHours = fh; workHours = wh; } string toString() const { int diff = abs(workHours - familyHours);

return name + " spent " + to_string(workHours) + " hours at work" + " and " + to_string(familyHours) + " with family " + "(diff = " + to_string(diff) + ")"; }

};

//------------------------------------------------------------------------- void sort(Comparable * a[], int size) { for (int i = 0; i compareTo(*a[j+1]) == 1) swap(a[j], a[j+1]); }

bool all_same(Comparable * a[], int size) { for (int i = 0; i compareTo(*a[i+1]) != 0) return false; return true; } //-------------------------------------------------------------------------

int main() { cout

sort(a, 3); for (int i = 0; i (a[i])->toString()

if (all_same(a, 3)) cout

cout

sort(b, 3); for (int i = 0; i (b[i])->toString()

if (all_same(b, 3)) cout

cout

sort(c, 3); for (int i = 0; i (c[i])->toString()

if (all_same(c, 3)) cout

cout

sort(d, 4); cout

image text in transcribed

OBJECTS OF DIFFERENT "

return 0; }

Find the missing class and the functions for the Outlook to appear like the image in c++

Sorting 3 slackers (based on the number of classes missed). Tania missed 50 classes Josh missed 73 classes Jimmy missed 81 classes * Not all slackers are the same! * The slackers are sorted! Sorting 3 workaholics (based on their work time). Workaholic worked 23 hours non-stop! Workaholic worked 23 hours non-stop ! Workaholic worked 23 hours non-stop ! * All workaholics are the same! * The workaholics are sorted! Sorting 3 work-family-balanced objects (based on the absolute difference between work and family time). Fatima spent 12 hours at work and 7 with family (diff = 5) Salwa spent 8 hours at work and 9 with family (diff = Ahmad spent 8 hours at work and 8 with family (diff 0) * The balanced objects are not all the same! * The balanced objects are sorted! Attempting to sort objects of mixed classes. terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Understand how to view variable importance in predicting turnover

Answered: 1 week ago

Question

using signal flow graph

Answered: 1 week ago