APlusGrades

Not Rated (0)

$15/per page/Negotiable

About APlusGrades

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing,Foreign Languages,Geography,Geology,Health & Medical,HR Management,Law,Management,Physics,Programming,Science,Statistics Hide all
Teaching Since: Jul 2017
Last Sign in: 364 Weeks Ago, 2 Days Ago
Questions Answered: 1850
Tutorials Posted: 1850

Education

  • Graduate in Biology and Nutrition, MBA Finance
    Florida State University
    Aug-2000 - Jul-2007

Experience

  • Ass. Relationship Manager
    Penn-Florida
    Mar-2009 - Feb-2016

Category > Computer Science Posted 19 Jul 2017 My Price 12.00

struct Vector2 { int x; int y; Vector2() : x(0), y(0) { } Vector2(int x, int y) { this->x = x; this->y = y; } bool is(int a_x, int a_y)..

I tried getting help from a tutor and they gave me code that would not compile correctly. I have attached the instructions to the lab and what I currently have. I would ask to add comments if possible on what you did. This assignment is due tonight.

The specified errors were:

1>d:visual studiogsp125 projectsgsp125_douglas_lab1gsp125_douglas_lab1gsp125_douglas_lab1entity.h(48): error C4716: 'Entity::getY': must return a value
1>d:visual studiogsp125 projectsgsp125_douglas_lab1gsp125_douglas_lab1gsp125_douglas_lab1entity.h(56): error C4716: 'Entity::getIcon': must return a value
1>d:visual studiogsp125 projectsgsp125_douglas_lab1gsp125_douglas_lab1gsp125_douglas_lab1entity.h(40): error C4716: 'Entity::getX': must return a value

 

struct Vector2 {

int x;

int y;

 

Vector2() :

x(0), y(0) {

 

}

 

Vector2(int x, int y) {

this->x = x;

this->y = y;

}

 

bool is(int a_x, int a_y) {

if (a_x == x && a_y == y) {

return true;

}

 

return false;

}

 

};

 

class Entity {

 

public:

Entity(int x, int y, char i) {

pos.x = x;

pos.y = y;

this->icon = i;

}

 

void setX(int x) {

this->pos.x = x;

}

 

int getX() {

this->pos.x;

}

 

void setY(int y) {

this->pos.y = y;

}

 

int getY() {

this->pos.y;

}

 

void setIcon(char i) {

this->icon = i;

}

 

char getIcon() {

this->icon;

}

 

private:

Vector2 pos;

char icon;

 

 

};

// lab1: simplegame_OOP

// <insert your name here>

// read main.cpp, and follow the instructions at the bottom of main.cpp

 

#include <iostream> // std::cout

#include "Entity.h"

 

using namespace std;

 

 

 

#include <windows.h> // SetConsoleCursorPosition(HANDLE,COORD)

#include <conio.h> // _getch()

 

 

enum GameState{

RUNNING,WIN,LOST,USER_QUIT

};

 

 

 

/**

 * moves the console cursor to the given x/y coordinate

 * @param x

 * @param y

 */

void moveCursor(int x, int y)

{

COORD c = {x,y};

SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);

}

 

int main()

{

// player data

Entity e(3,4,1);

 

 

 

// game data

GameState state = RUNNING;

int input;

Vector2 size(20,15);

Vector2 winPosition(size.x/2, size.y/2);

 

do

{

// draw the game world

moveCursor(0,0);

for(int row = 0; row < size.x; row++)

{

for(int col = 0; col < size.y; col++)

{

cout << '.';

}

cout << '\n';

}

// draw the player

moveCursor(e.getX(), e.getY());

cout << e.getIcon();

 

// get input from the user (wait for one key press)

input = _getch();

 

// process input from the user

switch(input)

{

case 'w':e.setY(e.getY() - 1);break;// move up

case 'a':e.setX(e.getX()-1);break;// move left

case 's':e.setY(e.getY()+1);break;// move down

case 'd':e.setX(e.getX()+1);break;// move right

case 27:state = USER_QUIT;break;// quit

}

// show the game state message

moveCursor(0, size.y+1);

switch(state)

{

case WIN:cout << "You WON! Congratulations!\n";break;

case LOST:cout << "You lost...\n";break;

}

 

if(winPosition.is(e.getX(),e.getY()))

{

state = WIN;

}else

{

state = LOST;

}

}

while(state == RUNNING);

 

// user must press ESCAPE before closing the program

cout << "press ESCAPE to quit\n";

while(_getch() != 27);

return 0;

}

 

Attachments:

Answers

Not Rated (0)
Status NEW Posted 19 Jul 2017 12:07 PM My Price 12.00

Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â-----------  -----------Tha-----------nk -----------you----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m Â----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I

Attachments

file 1500468270-Lab Source Code and Instructions 1.docx preview (848 words )
/-----------/ I-----------NST-----------RUC-----------TIO-----------NS ----------- //----------- -------------------------------------------------------- -----------// -----------Com-----------pil-----------e t-----------his----------- co-----------de.----------- Yo-----------u s-----------hou-----------ld -----------see----------- a -----------hap-----------py------------fac-----------e c-----------har-----------act-----------er -----------on -----------a f-----------iel-----------d o-----------f -----------// -----------per-----------iod-----------s. -----------You----------- ca-----------n m-----------ove----------- th-----------e c-----------har-----------act-----------er -----------wit-----------h t-----------he -----------'w'-----------, '-----------a',----------- 's-----------', -----------and----------- 'd-----------' k-----------eys-----------. -----------// ----------- //----------- Re-----------ad -----------thr-----------oug-----------h t-----------his----------- co-----------de!----------- Tr-----------y t-----------o u-----------nde-----------rst-----------and----------- it----------- be-----------for-----------e s-----------tar-----------tin-----------g t-----------he -----------ass-----------ign-----------men-----------t. ----------- //----------- Co-----------mme-----------nt -----------con-----------fus-----------ing----------- li-----------nes----------- wi-----------th -----------wha-----------t y-----------ou -----------thi-----------nk -----------cod-----------e i-----------s d-----------oin-----------g, -----------and----------- ex-----------per-----------ime-----------nt ----------- //----------- wi-----------th -----------exi-----------sti-----------ng -----------cod-----------e t-----------o t-----------est----------- yo-----------ur -----------und-----------ers-----------tan-----------din-----------g. ----------- //----------- On-----------ce -----------you----------- fe-----------el -----------com-----------for-----------tab-----------le
Not Rated(0)