Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CPSC 327 Project 5 Teams: None, please work individually on this project References: 1. Building and linking to a Static Library lectures and projects 2. Pointers Memory lectures and projects 3....

1 answer below »
CPSC 327
Project 5

Teams: None, please work individually on this project
References:
1. Building and linking to a Static Li
ary lectures and projects
2. Pointers Memory lectures and projects
3. Classes, Objects lectures and projects
Sample Code:
See 2 starter projects on course website
Topics covered by this project;
ï‚· Creating and using a static li
ary
ï‚· Using pointers to manipulate objects
ï‚· Using vectors to hold objects and pointers
ï‚· Class Heiarchies
ï‚· Abstract Base Classes
ï‚· Polymorphism
ï‚· Composition

Class Heiarchy
You are developing a class hierarchy for this project. An Abstract Base Class (ABC),
‘Smalltalk’ defines the hierarchy behavior. Most of your work in this class structure
will take place in Smalltalk.
Classes derived from Smalltalk must implement populatePhrases(). A function that
initializes the baseclass vector with phrases that are unique to that class type. For
instance, Smalltalk_American will populate its internal vector of strings with the
american phrases found in constants.h.
Additionally you are given a complete watch object. You may give or take a watch
from any instance of Smalltalk_American, ST_American_DonutEnthusiest or
Smalltalk_Brit. Note that watches cannot be created out of thin air, if you give one to
an instance you no longer have that watch, the instance does. See Smalltalk.h for
further guidance.
Please also provide a function (as specifies in Functions.h and outlined in
Functions.cpp) that generates a vector of unique pointers to objects derived from
smalltalk. Please pay attention to the hints I’ve left you in the implementation.
Please compile both projects using the C++11 language standard.
Li
ary
I would like you to fill in noted content in the following project structure.


Note the file ‘output’ under CONSOLE_OUTPUT_OF_SUCCESSFUL… It has a
listing of what a successful run should look like.
And create these 4 files
Fill in this file
All classes inherit publicly. The class hierarchy is as follows;
I have given you the header files and some of the implementation.
Testing
Please see the test application with the following name and file structure:

327_Proj_ST.cpp is a complete tester for the classes and functions you develop in the
lib. This application should link statically to the above li
ary. The projects as they
appear in the eclipse workspace.

Submission:
Only the following 5 files. Please do not zip them together, or embed them in a
directory structure. Just the 5 files.
Functions.cpp
Smalltalk_American.cpp
Smalltalk_Brit.cpp
Smalltalk.cpp
ST_American_DonutEnthusiest.cpp
Grading:
For each concrete class remember to push as much common functionality as possible
into base classes! This cuts down on repetitive code in derived classes.
5% Submission instructions followed
25% getPeople populated co
ectly with unique pointers
25% populatePhrases implemented co
ectly
XXXXXXXXXXsaySomething cycles co
ectly through available phrases
25% takeWatch, giveWatch, getTime co
ect
10% valgrind returns no e
ors
10% Code style (refactor repetitive code into functions, no magic numbers, no large
locks of empty space, no large chunks of commented out code, pushing as much
functionality in base class as possible, appropriate comments, your name at the top of
each file, etc.)
Answered Same Day Apr 06, 2021

Solution

Sandeep Kumar answered on Apr 06 2021
156 Votes
327 files/Functions.cpp
327 files/Functions.cpp
#include #include #include #include #include "./includes/Functions.h"
#include "./includes/Smalltalk_American.h"
#include "./includes/ST_American_DonutEnthusiest.h"
#include "./includes/Smalltalk_Brit.h"
#include "./includes/Watch.h"
#include "./includes/constants.h"
create a vector with appropriate numbers of Smalltalk_Brit,Smalltalk_American and ST_American_DonutEnthusiest
objects using unique pointers.  Since we are using c++11 returning this vector by value is fine since the 
compiler will move the vector on return rather than recreate it (this means there is no copy penalty)
std::vecto
std::unique_pt
Smalltalk
 getPeople(int numBrit,
        int numAmerican, int numbAmericanDonutEnthusiest,
        int numWatches) {
    
    std::vecto
std::unique_pt
Smalltalk
 talks;
    for (int i = 1; i <= numBrit; i++){
        std::unique_pt
Smalltalk> pBrit(new Smalltalk_Brit(i));
        talks.push_back(std::move(pBrit));
    }
    for (int i = 1; i <= numAmerican; i++){
        std::unique_pt
Smalltalk> pAmerican(new Smalltalk_American(i));
        talks.push_back(std::move(pAmerican));
    }
    for (int i = 1; i <= numbAmericanDonutEnthusiest; i++){
        std::unique_pt
Smalltalk> pUSDE(new ST_American_DonutEnthusiest);
        talks.push_back(std::move(pUSDE));
    }
    for (unsigned int i = 0; numWatches > 0 && i < talks.size(); i++){
        std::unique_pt
Watch> pWatch(new Watch());
        if(talks[i]->giveWatch(pWatch)){
            numWatches--;
        }
    }
    return talks;
}
327 files/Smalltalk.cpp
327...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here