Đã hoàn thành

C++ data structure program

THIS PROGRAM SHOULD WRITE IN C++!!!

Overview

You will use the following Shape interface to implement a Circle, Triangle, and Rectangle classes. Among the method(s) required by the interface...

Circles have a radius

Triangle have a base and height

Rectangle have a length and a width

You will be passed a file name contain shape data from the command line. Some kind of Executive class should read the file and use a ShapeContainer (see below) to store pointers to various shapes, using the specifications for each shape given in the file.

The file also contains commands to print the area of a given shape and to exit the program.

When a print command is issued, the information about the shape and it's area should be printed.

Shape Interface

You may NOT add any public methods to this class

#include <string>

class Shape

{

public:

virtual double area() const = 0;

virtual std::string shapeName() const = 0;

virtual ~Shape() {}

};

ShapeContainer

You may NOT add any public methods to this class

#include "Shape.h"

#include <stdexcept>

class ShapeContainer

{

public:

ShapeContainer(int size); //initialize pointers in m_arrayOfShapes to nullptr

~ShapeContainer();

double area(int index) const; //throws a std::runtime_error if index is invalid, meaning out of range OR index has nullptr

std::string shapeName(index) const; //throws a std::runtime_error if index is invalid, meaning out of range OR index has nullptr

void add(Shape* shapePtr, int index); //throws a std::runtime_error if index is invalid OR if shapePtr is nullptr

void remove(int index); //throws a std::runtime_error if the index is invalid OR there is no object to delete

private:

Shape** m_arrayOfShapes;

int m_size;

}

File Format

The first item in the file will be the size of the shape container, which cannot change despite how many adds are in the file. Following that will be lines containing one of the three following commands in any order:

ADD <index> <shape code> <shape data>

<index> is the index in the container to put the shape

<shape code> will be CIR, TRI, or REC for Circle, Triangle, and Rectangle respectively

<shape data> will the be radius, base and height, or length and width, of a Circle, Triangle, or Rectangle respectively

DELETE <index>

Deletes the shape at a given index

The index may be out of range or not yet set, in which case you must catch and handle the exception to gracefully recover and continue on

PRINT <index>

Prints the name and area of the shape at a given index, as shown below

The index may be out of range or not yet set, in which case you must catch and handle the exception to gracefully recover and continue on

EXIT

Ends the program

5

ADD 0 CIR 5.5

ADD 1 TRI 2.5 6.6

PRINT 0

ADD 2 REC 10.5 20.25

PRINT 99

PRINT 2

EXIT

Sample run:

Shape at index 0: Circle area = 95.0331

Shape at index 99: Does not exist

Shape at index 2: Rectangle area = 212.625

Exiting...

Kĩ năng: Lập trình C++, Kiến trúc phần mềm

Xem nhiều hơn: data structure program, data structure program report, turbo data structure program, program find shortest path graphs data structure, project php program data structure program, send data structure tcp connection program, postfix program data structure using, program data structure using stack postfix, simple program data structure, program postfix evaluation data structure, double hashing data structure program, c data structure, c data structure library, c data structure programs, c data structure tutorial, graph data structure in c program, merge sort program in data structure using c, stack program in data structure using c, c++ data structure assignment

Về Bên Thuê:
( 0 nhận xét ) Lawrence, United States

ID dự án: #21526925

Được trao cho:

kipdev13

Hello! Nice to meet you. I have read your proposal carefully and very interesting in your work. I have 10+ years experiences about C++/C#/Qt programming. Sure you will get good result. I will do my best for you and yo Thêm

$30 USD trong 1 ngày
(101 Đánh Giá)
6.3

11 freelancer đang chào giá trung bình $28 cho công việc này

usman1493

⭐⭐⭐⭐⭐ Hello Sir, Greetings. A Team of Expert Software Developers is here. We can help you with your C++ Project. This is an initial bid. Feel free to message me. We can discuss about the details over chat. Regards. ⭐⭐ Thêm

$20 USD trong 1 ngày
(158 Nhận xét)
6.5
Programmer59

Hello Sir, I am professional C++ developer with having more than 5 year's experience in this field. I read your project description and I am interested in it I need some more information related to your project Can we Thêm

$30 USD trong 2 ngày
(53 Nhận xét)
6.0
IFI91

Hello, Sir Weebside Inc. is a professional freelancer service provided to worthy clients like you. We can provide our best developers to provide you High-Quality Product with 100% Delivery Rate, 100% Satisfaction. Havi Thêm

$19 USD trong 1 ngày
(47 Nhận xét)
5.0
WongGanteng

Hello. How are you. I'm software engineer and algorithm expert. I have many experiences in c, c++, c#, java, python, node.js. I can complete your project successfully. Thanks.

$100 USD trong 1 ngày
(3 Nhận xét)
3.8
greencoders

Hello!I I am very interested in your post project. I am really looking for this kind of project for a long time in freelancer since i have rich experience on it. I think this project is very suitable for me and i am s Thêm

$10 USD trong 1 ngày
(5 Nhận xét)
3.5
shaheryartariq90

Hi ! I have read your project description .I have the required skills in this technology to do this. I HAVE DONE THIS KIND OF WORK PREVIOUSLY. I can show you my work too. For getting started you can reach me anytime Thêm

$20 USD trong 7 ngày
(2 Nhận xét)
2.4
percdrumer

Dear sir I have studied your requirement carefully and I can complete your project in 1 ~ 2 hours if you hire me. Thanks for reading.

$20 USD trong 7 ngày
(1 Nhận xét)
1.0
codeunitech

Hello! I am very interested in your post project. While I read your description carefully, I was excited with feeling that I would be able to satisfy for your requirements in this job. We can negotiate on price/Budget Thêm

$20 USD trong 1 ngày
(1 Nhận xét)
0.4
Choosearts

Hello, Thanks for positing this job, We are great on creating print materials and project we have completed its on our portfolio you can check below. Portfolio https://www.freelancer.com/u/Choosearts?page=portfolio&r Thêm

$30 USD trong 3 ngày
(0 Nhận xét)
0.0
manu83tudo

- previous experience in such topics ; - eager to discuss a lot in this chat stream ; - degree stats / maths ;

$10 USD trong 1 ngày
(0 Nhận xét)
0.0