Question

I need help doing the requirements listed below. Please don't delete comments. #include #include #include #include...

I need help doing the requirements listed below. Please don't delete comments.

#include
#include

#include

#include "Imager.h"

/// 5 points : The program compiles without errors and warnings

/// 5 points : The program operates correctly

using namespace std;

int main()
{
/// 2 points: Create an instance of two integers called "inX" and "inY".


/// 2 points: Create an instance of the Imager class called "myImager".


/// 2 points: Create a file input stream called "fileInStream".


/// 2 points: Open the file "message.txt" for "fileInStream".


/// 2 points: Verify that "fileInStream" open correctly. Print a
/// error message if it does not and immediately exit the program.


do
{
/// 2 points: Read two integers at a time from "fileInStream".
/// Store the integer values into "inX" and then "inY" respectively.


if(fileInStream.eof())
{
break;
}

/// 4 points: Call the append member function of "myImager". The
/// member function, declared in ImagerBase.h, has the form
///
/// void append(int, int)
///
/// Pass the value of "inX" as the first argument and the value of
/// "inY" as the second argument.


} while(!fileInStream.eof());

/// 2 points: Close "fileInStream"


/// 2 points: Call the "myImager" member functions :
///
/// int getWidth()
/// int getHeight()
///
/// Use the values returned from the function
/// calls to complete the call to the sf::RenderWindow below
sf::RenderWindow window(sf::VideoMode(/* ADD MISSING CODE HERE */), "Message");

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}

window.clear(sf::Color::White);

/// 4 points: Call the "window" draw function and pass "myImagert" as the
/// argument.

window.display();
}

return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int main()
{
/// 2 points: Create an instance of two integers called "inX" and "inY".

int inX,inY;
/// 2 points: Create an instance of the Imager class called "myImager".

Imager myImager;
/// 2 points: Create a file input stream called "fileInStream".

ifstream fileInStream;
/// 2 points: Open the file "message.txt" for "fileInStream".

fileInStream.open("message.txt");
/// 2 points: Verify that "fileInStream" open correctly. Print a
/// error message if it does not and immediately exit the program.

if(fileInStream.fail())

{

cerr<<"file cant be opened for reading";

exit(0);

}
do
{
/// 2 points: Read two integers at a time from "fileInStream".
/// Store the integer values into "inX" and then "inY" respectively.

fileInStream>>inX>>inY;
if(fileInStream.eof())
{
break;
}

/// 4 points: Call the append member function of "myImager". The
/// member function, declared in ImagerBase.h, has the form
///
/// void append(int, int)
///
/// Pass the value of "inX" as the first argument and the value of
/// "inY" as the second argument.

myImager.append(inX,inY);
} while(!fileInStream.eof());

/// 2 points: Close "fileInStream"

fileInStream.close();
/// 2 points: Call the "myImager" member functions :
///
/// int getWidth()
/// int getHeight()
//

/// Use the values returned from the function
/// calls to complete the call to the sf::RenderWindow below
sf::RenderWindow window(sf::VideoMode(myImager.getWidth(),myImager.getHeight()), "Message");

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}

window.clear(sf::Color::White);

/// 4 points: Call the "window" draw function and pass "myImagert" as the
/// argument.

window.draw(myImager);

window.display();
}

return 0;
}

Add a comment
Know the answer?
Add Answer to:
I need help doing the requirements listed below. Please don't delete comments. #include #include #include #include...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help meeting these requirements. Please don't delete comments. #ifndef IMAGER_H_INCLUDED #define IMAGER_H_INCLUDED #include "ImagerBase.h"...

    I need help meeting these requirements. Please don't delete comments. #ifndef IMAGER_H_INCLUDED #define IMAGER_H_INCLUDED #include "ImagerBase.h" /// 4 points: Define a class called "Imager" that inherits /// public-ly from the "ImagerBase" class { /// 4 points: Declare a public member functions called /// "getWidth" that returns an int and has no parmeters /// 4 points: Declare a public member functions called /// "getHeight" that returns an int and has no parmeters }; #endif // IMAGER_H_INCLUDED

  • please do in java and comments the code so i can understand Requirements: Create a Java...

    please do in java and comments the code so i can understand Requirements: Create a Java class named “MyRectangle2D.java”. Your class will have double two variables named x and y. These will represent the center point of your rectangle. Your class will have two double variables named width and height. These will represent the width and height of your rectangle. Create getter and setter methods for x, y, width, and height. Create a “no argument” constructor for your class that...

  • Example program #include <string> #include <iostream> #include <cmath> #include <vector> using namespace std; vector<int> factor(int n)...

    Example program #include <string> #include <iostream> #include <cmath> #include <vector> using namespace std; vector<int> factor(int n) {     vector <int> v1;     // Print the number of 2s that divide n     while (n%2 == 0)     {         printf("%d ", 2);         n = n/2;         v1.push_back(2);     }     // n must be odd at this point. So we can skip     // one element (Note i = i +2)     for (int i = 3; i <=...

  • Please in C Language Thank you! The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO:...

    Please in C Language Thank you! The following program source code is incomplete 1 #include <stdio.h> 2 3 // TODO: 1) Add the typedef here: 5// TODO: 2) Modify the parameter of repeat to add irn the function pointer for the function to be called repeatedly: 8 void repeat (int times) for (int k 0; k < times; ++k) 12 // TODO: 3) Add the call to the function pointer here: 14 15 17 void test (void) 18 printf("Test!\n"); 19...

  • I need help with my homework please. I should write this program in C++ language and...

    I need help with my homework please. I should write this program in C++ language and use Inventory.h file (header file), Inventory.cpp file (implementation file), and main.cpp file (main program). This is the program: Demonstrate the class in a driver program. Input validation, don’t accept negative values for item number, quantity, or cost. 6. Inventory Class Design an Inventory class that can hold information and calculate data for items ma retail store's inventory. The class should have the following private...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   and please put comment with code! Problem:2 1. Class Student Create a "Hello C++! I love CS52" Program 10 points Create a program that simply outputs the text Hello C++!I love CS52" when you run it. This can be done by using cout object in the main function. 2. Create a Class and an Object In the same file as...

  • can someone please double check my code here are the requirements please help me fulfill the...

    can someone please double check my code here are the requirements please help me fulfill the requirements Using the material in the textbook (NumberList) as a sample, design your own dynamic linked list class (using pointers) to hold a series of capital letters. The class should have the following member functions: append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges...

  • Please I am in a hurry, I need an answer asap. I have seen an answer previously regarding to this...

    Please I am in a hurry, I need an answer asap. I have seen an answer previously regarding to this question, however I found a lot of mistakes on it, where the guy declared a public class, which is not a thing in C language. Furthermore it is important to divide the question into two C files, one for part a and one for part b. hw2 Merge Sort algorithm using 2 processes a.) Define an integer array of 100...

  • Please complete Part 1. The code is also below: #include <pthread.h> #include <iostream> using namespace std;...

    Please complete Part 1. The code is also below: #include <pthread.h> #include <iostream> using namespace std; void *PrintHello(void *arg) { int actual_arg = *((int*) arg); cout << "Hello World from thread with arg: " << actual_arg << "!\n"; return 0; } int main() { pthread_t id; int rc; cout << "In main: creating thread \n"; int t = 23; rc = pthread_create(&id, NULL, PrintHello, (void*) &t); if (rc){ cout << "ERROR; return code from pthread_create() is " << rc <<...

  • Hi I need some help in C programing class and I doing one of the exercise...

    Hi I need some help in C programing class and I doing one of the exercise so that I can get better at coding. Suppose you are asked to design a software that helps an elementary school student learn multiplication and division of one-digit integer numbers. The software allows the student to select the arithmetic operation she or he wishes to study. The student chooses from a menu one of two arithmetic operations: 1) Multiplication and 2) Division (quotient). Based...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT