Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

These are the codes CellId.h #pragma once #include struct CellId { int row; int column; }; // // toCellId // // Purpose: To get an

image text in transcribedimage text in transcribed

These are the codes

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 Modify 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 class . Change the initialization function into a constructor with arguments. Add a default constructor that initializes things to 0 or empty string. Please note that you should use a for loop to initialize 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 twa sample runs that you can try in the lab: hercules[s]x main please describe the cat Please enter a length: 48 Please enter a heaght: 25 please enter a tail length: 31 please enter an eye colour: blue Please enter a Jescripciun ut the fur (lung, 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 mas mediun fur ------------------------------ This is myCat: Length: 13 Height: 25 Tail Length: 31 FYe Colour: blue Classitication: short kat Colours: grey white . 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 sarple runs that you can try in the lab: Hercules[5]X / min Please describe the cos Please enter a length: 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 (long, nedium, short, none): short Please enter the colours of the fur (separated by a space or a newline character). Add "donc" at the end: grey white donc The average cat has mediun fur This is myCat: pagth: 43 Height: 25 Tail Length: 31 Eye Colour: blue Fur Classification short Kal Colours: grey while Hly cat is taller than the average cat Hercules [6] hercules[6]} .main Please describe the cat please enter a length: 44 Please enter a heiti 22 Please enter a tail length: 30 Please enter an eye colour: yellow Please enter a description of the fur (lone, nedum, short, none): long Please enter the colours of the fur (separated by a space or a newline character). Add "done" at the end: black white orange done The average cat as medium fur This is tyCat: Length: 44 Height: 22 Tail Length: 30 Fya Colour: yellow Fur classification: lora Cet colours: black white orange My cat is Sherler than the average cal My cats a calico 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 Modify 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 class . Change the initialization function into a constructor with arguments. Add a default constructor that initializes things to 0 or empty string. Please note that you should use a for loop to initialize 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 twa sample runs that you can try in the lab: hercules[s]x main please describe the cat Please enter a length: 48 Please enter a heaght: 25 please enter a tail length: 31 please enter an eye colour: blue Please enter a Jescripciun ut the fur (lung, 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 mas mediun fur ------------------------------ This is myCat: Length: 13 Height: 25 Tail Length: 31 FYe Colour: blue Classitication: short kat Colours: grey white . 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 sarple runs that you can try in the lab: Hercules[5]X / min Please describe the cos Please enter a length: 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 (long, nedium, short, none): short Please enter the colours of the fur (separated by a space or a newline character). Add "donc" at the end: grey white donc The average cat has mediun fur This is myCat: pagth: 43 Height: 25 Tail Length: 31 Eye Colour: blue Fur Classification short Kal Colours: grey while Hly cat is taller than the average cat Hercules [6] hercules[6]} .main Please describe the cat please enter a length: 44 Please enter a heiti 22 Please enter a tail length: 30 Please enter an eye colour: yellow Please enter a description of the fur (lone, nedum, short, none): long Please enter the colours of the fur (separated by a space or a newline character). Add "done" at the end: black white orange done The average cat as medium fur This is tyCat: Length: 44 Height: 22 Tail Length: 30 Fya Colour: yellow Fur classification: lora Cet colours: black white orange My cat is Sherler than the average cal My cats a calico

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

What is one of the purposes of the Small Business program

Answered: 1 week ago

Question

Solve for x: 2(3x 1)2(x + 5) = 12

Answered: 1 week ago

Question

Understand how customers respond to effective service recovery.

Answered: 1 week ago