Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help me with the lap in c++. below are the programs you are meant to edit thank you CellId.h file main.cpp file cat.h file

please help me with the lap in c++. below are the programs you are meant to edit

thank you image text in transcribed

image text in transcribed

CellId.h file

image text in transcribed

image text in transcribed

image text in transcribed

main.cpp file

image text in transcribed

image text in transcribed

cat.h file

image text in transcribed

here are the codes in type format

CellId.h

#pragma once

#include

struct CellId { int row; int column; };

// // toCellId // // Purpose: To get an object of CellId with given position on board // Parameter(s): // row1: row position on board // column1: column position on board // Precondition(s): N/A // Returns: CellId object that created // Side Effect: N/A // CellId toCellId(int row1, int column1);

// // isOnBoard // // Purpose: To check that given CellId object's position is on board or not // Parameter(s): // cell_id: object who's position need to check // Precondition(s): N/A // Returns: true if position on board otherwise false // Side Effect: N/A // bool isOnBoard(const CellId& cell_id);

// // isOnBoard // // Purpose: To check that given position is on board or not // Parameter(s): // str: position on board // Precondition(s): N/A // Returns: true if position on board otherwise false // Side Effect: N/A // bool isOnBoard(const std::string& str);

// // toCellId // // Purpose: To get an object of CellId with given position on board // Parameter(s): // str: cell position on board // Precondition(s): // isOnBoard(str) == true // Returns: CellId object that created // Side Effect: N/A // CellId toCellId(const std::string& str);

// // printCellId // // Purpose: To print cell position of given CellId object // Parameter(s): // cell_id: object whose position need to print // Precondition(s): N/A // Returns: N/A // Side Effect: N/A // void printCellId(const CellId& cell_id);

Main.cpp

#include "Cat.h" #include using namespace std;

int main() { Cat averageCat, myCat;

string colours[5]; colours[0] = "orange"; colours[1] = ""; initCat (averageCat, 45, 24, 28, "green", "medium", colours);

readCat (myCat);

cout

cout

Cat.h

#ifndef __Cat_h__ #define __Cat_h__ #include using namespace std;

struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; };

void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&);

#endif

4. Lab Exercise - Convert a Structure to a Class Convert a structure into a class implementation Details: Start with the repl code provided to you Modiy all of the functions so that they are member functions. Use the scope resolution operator (-) to show that an implementation of a function is part of a cha Change the initialization function into a constructor with arguments, Add a default constructor that initializes things to or empty string. Please note that you should use a for loop to initiative all the values of furcolours Add one getter to return the furclassification . Modify the calls in main to reflect the change in the functions . Be sure to add the keyword const after functions that do not change the data, . If you want, you can turn the isTaller function into an overloaded operator> Here are two sample runs that you can try in the lab hercules[5] in Please escribe the cat Please enter a longth: 48 Please enter a height 25 Please enter a tail Length: 31 Please enter an eye colour: blue Please enter a description of the fur (lont, medium, short, none) short please enter the colours of the fur (separated by a space or a newline character). Add done at the end grey white done The average cat has medius fun us is myCat Length: 48 Height: 25 Tail Length: 31 Eye Colour blue Fur Classification short cat colours: rey white y cat is taller than the average cat hercules constanter functions that do not change the data If you want, you can turn the staller function into an overloaded operator Here are two sample runs that you can try in the lab Flest tail length Peter an eye color blue Please enter description of the forcon me, hot, noe short Please the colours of the fur (separated by corne What). Addon" at the end grey white done The average cat has medium fur This is wat Length Height: 25 Tail Length: 11 y Colour blue Fur Classification short Cat Colours are white y cat is taller than the average at hercules[6] hercules[6]/in Please describe the at Please enter length 44 Please enter a height 22 Please enter tail length 30 please enter an eye colour yellow Please enter a description of the fur (lone, ed short, none) long Please enter the colours of the fur (separated by a space of the character). Adit done at the end black white orange done The average cat has medium fun This is mycat Length High: 22 Tail Length: 30 Eye Colour yellow Fur Classification long Cat Colours: black white orange y cat is shorter than the weate cat catcalico Attach Cath rate once include estrings Estruct Ceild 2 int rowe int column; 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 // V tocellid // // Purpose: To get an object of Ce celuid with given position on board // Parameter(s): // ci) rowi: row position on board // columni: column position on board Precondition(s): N/A W Returns: Cellid object that created // Side Effect: N/A / Cellid tocellId(int rowl, int column); I // // isOnBoard // // Purpose: To check that given Cellid object's position is on board or not 1Parameter(s): // cell_id: object who's position need to check 1/ Precondition(s): N/A Ihan.co OnBoard Purpose to check that given Celld object's position is on board or not Parameters): st> cell_id: object who's position need to check W Precondition(s): N/A VI Returns: true if position on board otherwise false Side Effect: N/A so 31 32 bool isOnBoard(const Cellid& cell id); 34 35 36 37 38 39 40 42 42 43 BI // isOnBoard W Purpose: To check that given position is on board or not 1 Parameter(s): stnt position on board // Precondition(s): N/A // Returns: true if position on board otherwise false W Side Effect: N/A // bool isOnBoard(const std::string& str); I I 45 46 47 48 49 5@ 51 52 53 54 100 56 EI// toCellid 17 1 Purpose: To get an object of Cellid with given position on board Il Parameter(s): str: cell position on board // Precondition(s): main.cpp Parameter s s str: cell position on board 5 Precondition(s) 55 isOnBoard(str) = true 56 W Returns: Cellid object that created 57 W Side Effect: N/A 58 w 59 Cellid toCelld(const std::string& str); 60 61 // 62 // printcelled 63 17 64 1/ Purpose: To print cell position of given Cellid object 65 1/ Parameter(s): 5611 cell_id: object whose position need to print 57 // Precondition(s): N/A 68 // Returns: N/A 69 Side Effect: N/A 70 // 71 void printcellid(const Cellid& cell_id); 72 I Celldh main.cpp Cath Miscellaneous Files (Global Scope) include "Cat.h" #include using namespace std; 10 12 13 Fint main() Cat averagecat, myCat; string colours [5]; colours [@] = "orange", colours [1] = ""; initCat (averagecat, 45, 24, 28, "green", "medium", colours); 15 16 17 18 19 2e 21 22 23 24 25 26 readCat (myCat); cout 8 using namespace std; 9 le Estruct Cat 11 12 double length; 13 double height; 14 double tailLength; 15 string eyeColour; I 16 string furClassification; //long, medium, short, none 17 string furColours[5]; 18 }; 19 20 void initCat (Cat&, double, double, double, string, string, const string(1) 21 void readCat (Cat); 22 void printCat (const Cat&); 23 bool isCalico (const cat) bool isTaller (const Cat&, const Cat&); 25 26 endir

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

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago