Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Task Overator overloading Described below is a simple UML diagram for the tome class. This is the class that will be used to

In C++

Task Overator overloading

Described below is a simple UML diagram for the tome class. This is the class that will

be used to overload a number of operators so that managing the archive will be easier.

tome

-references: string [10]

-tomeName: string

-author: string

-spellsStored:int

----------------------------

+tome(name:string, tomeSize:int,author:string)

+tome(name:string, tomeSize:int,author:string, initialList:string *)

+~tome()

+getTomeSize():int

+getSpell(i:int) const:string

+getReferences(): string *

+getName():string

+getAuthor():string

+operator+(add:tome &):tome

+friend operator<<(output:ostream &,t:const tome &):ostream &

+operator=(oldTome:const tome &):void

The class variables are described as follows:

references: A array of string names that represent the names of spells that reside in

the tome. Each is a separate spell.

tomeName: The name of the tome as a string. Examples include "The Magisterial

Cookbook" and "Eye of Newt & Other Curses"

author: The name of the original author(s) of the tome as represented by a string.

spellsStored: the number of spells, out of a total of 10, currently stored in the tome.

The class methods and their behaviour is described as follows:

tome(name:string, tomeSize:int,author:string): This constructor receives a number

of arguments and instantiates them in the class.

tome(name:string, tomeSize:int,author:string, initialList:string *): The class con-

structor. It will receive a number of arguments and then instantiate all of the class

variables.

tome: The class destructor with a default behaviour.

getTomeSize: Returns the number of spells stored in the tome.

getSpell: This accepts an array index and returns the spell stored at the index.

getName: This returns the tome name.

getReferences: Returns the list of spells kept in the tome.

getAuthor: Returns the name of the author(s) of the tome.

operator+: This operator will enable two tomes to be added together. If A and

B are tomes, then C=A+B should combine all of the spells contained in A and

all in B into a bigger list and store them in C. Additionally, the authors of both

tomes must be present as well with each author after the rst, appearing with a

comma separating them. Finally, the name of the tome is taken as the name of

the component tome with the larger list of spells. If the two are equal, simply take

the rst tome then. Note that the new tome created should still remain even if the

component tomes are deleted. The most a tome can hold is 10 so you can assume

that tomes created in this way will not add tomes whose spell counts equal more

than 10.

operator<<: This is an overload of the outstream operator. When called on a tome,

such as cout<

of the information of the tome in a neatly formatted way. Remember the newlines

at the end of your output lines. The format is:

Tome Name: Grimoires and Hexes Vol 2

Author: J. Wiggle, C. McCormick

References: Best Practices for Curses, Simple Potions 101, Magic Vol 1

operator=: This is an overload of the assignment operator. With this operation

overload, it should be possible to assign an existing instance of a tome to a new

instance.

You will be allowed to use the following libraries: cstring, string, iostream.

Your submission must contain tome.cpp,

tome.h, main.cpp and a makefile.

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions