Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help creating the store() function using pointers Start of File: #include #include #include #include #include #include //--- Definition of constants: ---// // PURPOSE: To

Need help creating the store() function using pointers

Start of File:

#include #include #include #include #include #include

//--- Definition of constants: ---// // PURPOSE: To tell how many flowers each bee hive must visit. const int NUM_FLOWERS_TO_COLLECT = 5;

// PURPOSE: To tell the number of bee hives that exist. const int NUM_BEE_HIVES = 4;

// PURPOSE: To hold the names of the flowers: const char* FLOWER_NAME_ARRAY[] = { "Jasmine", "Daffodil", "Daisy", "Dandelion", "Venus fly trap", "Tumbleweed", "Kudzu", "Poison Ivy" };

// PURPOSE: To tell how many flower names there are. const size_t NUM_FLOWER_NAMES= sizeof(FLOWER_NAME_ARRAY)/sizeof(const char*);

//--- Definition of classes and structs: ---//

// PURPOSE: To represent a flower. class Flower { // I. Member vars: // PURPOSE: To hold address of the name of the flower as a C-string. const char* nameCPtr_;

// PURPOSE: To hold the address of the Flower instance after '*this' one, // or 'NULL' if there is no such Flower. Flower* nextPtr_;

// II. Disallowed auto-generated methods: // No copy constructor: Flower (const Flower&);

// No copy assignment op: Flower& operator= (const Flower&);

protected : // III. Protected methods:

public : // IV. Constructor(s), assignment op(s), factory(s) and destructor: // PURPOSE: To make '*this' a stand-alone Flower instance with a randomly- // chosen name. No parameters. No return value. Flower () : nameCPtr_(FLOWER_NAME_ARRAY[rand() % NUM_FLOWER_NAMES] ), nextPtr_(NULL) { }

// PURPOSE: To release the resources of '*this'. No parameters. No // return value. ~Flower () { }

// V. Accessors: // PURPOSE: To return the name of the flower. No parameters. const char* getNameCPtr () const { return(nameCPtr_); }

// PURPOSE: To return the address of the Flower instance after '*this' one, // or 'NULL' if there is no such Flower. Flower* getNextPtr () const { return(nextPtr_); }

// VI. Mutators: // PURPOSE: To note that the next flower in the list has address // 'newNextPtr'. No return value. void setNextPtr (Flower* newNextPtr ) { nextPtr_ = newNextPtr; }

// VII. Methods that do main and misc work of class:

};

class Garden { // I. Member vars: // YOUR MEMBER VARS HERE Flower* startPtr_; Flower* endPtr_; int GARDEN_LENGTH;

// II. Disallowed auto-created methods: // No copy constructor: Garden (const Garden&);

// No copy assignment op: Garden& operator= (const Garden&);

protected : // III. Protected methods:

public : // IV. Constructor(s), assignment op(s), factory(s) and destructor: // PURPOSE: To initialize '*this' to an empty garden. No parameters. // No return value. Garden () { // INITIALIZE HERE beginPtr_=NULL; endPtr_=NULL; GARDEN_LENGTH=0;

}

// PURPOSE: To release the resources of '*this'. No parameters. // No return value. ~Garden () { // GET RID OF LIST HERE }

// V. Accessor(s): // PURPOSE: To hold length of '*this' list. int getNumFlowers () const { return(GARDEN_LENGTH); /* CHANGE THAT 0 */}

// VI. Mutator(s):

// VII. Methods that do main and misc. work of class: // PURPOSE: To add the Flower with address 'flowerPtr' at the back of // '*this' Garden of Flower instances. No return value. void store (Flower* flowerPtr ) //WHAT GOES HERE???

}

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Define span of management or define span of control ?

Answered: 1 week ago

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

2. Describe how technology can impact intercultural interaction.

Answered: 1 week ago