Related questions
C++ CODE HELP NEEDED
NEED MISSING CODE THAT WILL
- Read an integer as the number of Goat objects.
- Assign myGoats with an array of that many Goat objects. For each object, call object's Read() followed by the object's Print().
Ex: If the input is 2 5 87 7 71, then the output is:
Goat's age: 5
Goat's weight: 87 Goat's age: 7 Goat's weight: 71 Goat with age 7 and weight 71 is deallocated. Goat with age 5 and weight 87 is deallocated.
#include <iostream>
using namespace std;
class Goat {
public:
Goat();
void Read();
void Print();
~Goat();
private:
int age;
int weight;
};
Goat::Goat() {
age = 0;
weight = 0;
}
void Goat::Read() {
cin >> age;
cin >> weight;
}
void Goat::Print() {
cout << "Goat's age: " << age << endl;
cout << "Goat's weight: " << weight << endl;
}
Goat::~Goat() { // Covered in section on Destructors.
cout << "Goat with age " << age << " and weight " << weight << " is deallocated." << endl;
}
int main() {
Goat* myGoats = nullptr;
int count;
int i;
/* Your code goes here */
delete[] myGoats;
return 0;
}
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- Problem Description - JAVA PROGRAMMING Use a Two-dimensional (3x3) array to solve the following problem: Write an application that inputs nine numbers, each of which is between 1 and 10, inclusive. Display the array after the user inputs each value. Rotate/flip the array by changing places. Make the rows columns and vice versa. You have to move the elements to their new locations. Remember to validate the input and display an error message if the user inputs invalid data. Documentation and the screenshot(s) of the results. Example: 1 2 3 4 5 6 7 8 9 the result will be : 1 4 7 2 5 8 3 6 9arrow_forwardIn Java Assignment 5B : Maze Game! 2D Arrays can be used to store and represent informationabout video game levels or boards. In this exercise, you will use this knowledge tocreate an interactive game where players attempt to move through a maze. You willstart by creating a pre-defined 2D array with the following values:{"_","X","_","X","X"}{"_","X","_","X","W"}{"_","_","_","X","_"}{"X","X","_","_","_"}{"_","_","_","X","X"}You will then set the player (represented by "O") at index 0, 0 of the array, the top-leftcorner of the maze. You will use a loop to repeatedly prompt the user to enter adirection ("Left", "Right", "Up", or "Down"). Based on these directions, you will try tomove the player.• If the location is valid (represented by "_"), you will move the player there• If the location is out of bounds (e.g. index 0, -1) or the command is invalid, youwill inform the player and prompt them to enter another direction• If the location is a wall (represented by "X"), you will tell the...arrow_forwardWhat would be the missing line of codes?arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education