Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In c++ , only header file .h and main. Use virtual destructors, use operators, use virtual functions members, use of Abstract class. Create a class

In c++ , only header file .h and main. Use virtual destructors, use operators, use virtual functions members, use of Abstract class.

Create a class named JewelryBox class which inherits from PlainBox which in turn inherits from BoxInterface

The class given below are the classes to inherit JewerlyBox, can be used as is or for reference. Can be modify too

a) Create a class named Jewelry with the following attributes

i. Gender: If the jewelry is for women, men or children

ii. Jewelry Type: If it is ring. Necklace, chains, bracelet, earrings

iii. Gold Metal Weight: 24k, 14k, 18k or 24k

iv. Price: Price of the garment

v. Metal: Type of metal, white gold, yellow, silver ... etc

b) Create a class named Watches with the following attributes

i. Gender Watch: Whether the watch is female, male or child

ii. Watch Brands: Casio, Bulova, Citizen, Rolex, Invicta

iii. Price: Price of the watch

c. Create an instance of type JewelryBox and another of type JewelryBox using pointers. Ask for user data and print your content.

//class Plainbox

#ifndef PlainBox_hpp

#define PlainBox_hpp

#include

#pragma once

#include

using namespace std;

template<class ItemType>

class PlainBox {

private:

ItemType item;

public:

PlainBox();

PlainBox(const ItemType& theItem);

virtual ~PlainBox();

void setItem(const ItemType& theItem);

ItemType getItem() const;

};

template<class ItemType>

PlainBox::PlainBox() {

cout << "PlainBox constructor executing ";

}

template<class ItemType>

PlainBox::PlainBox(const ItemType& theItem) {

setItem(theItem);

}

template<class ItemType>

PlainBox::~PlainBox() {

cout << "PlainBox destructor executing ";

}

template<class ItemType>

void PlainBox::setItem(const ItemType& theItem) {

item = theItem;

}

template<class ItemType>

ItemType PlainBox::getItem() const {

return item;

}; #endif /* PlainBox_hpp */

//class BoxInterface

#ifndef BoxInterface_hpp

#define BoxInterface_hpp

#include

class BoxInterface{

public :

virtual ~BoxInterface() {}

virtual void setItem( const ItemType &theItem) = 0;

virtual ItemType getItem() const = 0;

}; #endif /* BoxInterface_hpp */

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions