Question

Location row : int = -1 col : int = -1 setLocation(row : int, col : int) getRow(): int getColl): int isEmpty(): bool Details
Function details are as follows: Location() Initialize row to - 1 (constructor) Initialize col to - 1 getRow() getColo return
5. Add a main() function (either at the bottom of location.cpp or in a separate file) to test your class. You can comment out
Declaration of the Location class. This class is used to designate a location on a 2-dimensional board. It will be leveraged
for a location @param @return none int (the row) int getRow(); Accessor function that gets the col value for a location @para
Very Important Stuff All programs should follow the classs coding conventions. Submit the following files: • location.h • lo

PLEASE COMPLETE IN C++ LANGUAGE
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

// Location.h

#ifndef LOCATION_H
#define LOCATION_H

class Location
{
public:
Location();
void setLocation(int row,int col);
int getRow();
int getCol();
bool isEmpty();

private:
// Declaring variables
int row;
int col;

};
#endif

==========================

// Location.cpp

#include <iostream>
using namespace std;
#include "Location.h"

Location::Location()
{
this->row=-1;
this->col=-1;

}
void Location::setLocation(int row,int col)
{
this->row=row;
this->col=col;   
}
int Location::getRow()
{
return row;
}
int Location::getCol()
{
return col;
}
bool Location::isEmpty()
{
if(row==-1 && col==-1)
{
return true;
}
else{
return false;
}
}


============================

// main.cpp

#include <iostream>
using namespace std;
#include "Location.h"
int main()
{
Location loc;
if(loc.isEmpty())
{
cout<<"Location is Empty."<<endl;
}
else{
cout<<"Location is not Empty"<<endl;
}

loc.setLocation(4,5);
if(loc.isEmpty())
{
cout<<"Location is Empty."<<endl;
}
else{
cout<<"Location is not Empty"<<endl;
}

cout<<"Location is :("<<loc.getRow()<<","<<loc.getCol()<<")"<<endl;

return 0;
}

=============================

Output:

1./Location Location is Empty. Location is not Empty Location is :(4,5) Press any key to continue.


=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
PLEASE COMPLETE IN C++ LANGUAGE Location row : int = -1 col : int = -1...
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
  • Implement a class CSVReader that reads a CSV file, and provide methods: int numbOfRows() int numberOfFields(int...

    Implement a class CSVReader that reads a CSV file, and provide methods: int numbOfRows() int numberOfFields(int row) String field(int row, int column) Please use the CSVReader and CSVReaderTester class to complete the code. I have my own CSV files and cannot copy them to here. So if possible, just use a random CSV file. CSVReader.java import java.util.ArrayList; import java.util.Scanner; import java.io.*; /**    Class to read and process the contents of a standard CSV file */ public class CSVReader {...

  • Please help i need a C++ version of this code and keep getting java versions. Please...

    Please help i need a C++ version of this code and keep getting java versions. Please C++ only Purpose: This lab will give you experience harnessing an existing backtracking algorithm for the eight queens problem, and seeing its results displayed on your console window (that is, the location of standard output). Lab A mostly complete version of the eight queens problem has been provided for you to download. This version has the class Queens nearly completed. You are to provide...

  • I need help with the following and written in c++ thank you!: 1) replace the 2D...

    I need help with the following and written in c++ thank you!: 1) replace the 2D arrays with vectors 2) add a constructor to the Sudoku class that reads the initial configuration from a file 3) adds a function to the Sudoku class that writes the final Sudoku grid to a file or to the standard output device, cout. Sudoku.h #pragma once /* notes sudoku() default constructor precondition : none postcondition: grid is initialized to 0 sudoku(g[][9]) 1-parameter constructor precondition...

  • ================Data Structures C++=============== – Implement the Eight Queens Problem This is a...

    ================Data Structures C++=============== – Implement the Eight Queens Problem This is an object oriented program. This is #1 on page 187 of your book with ONE difference, I’m requiring you add a client program to test your code (a main). If you have the old book the question says “Complete the Queen and Board class for the Eight Queens problem.” On page 179 of your book is a function placeQueens that solves the Eight Queens problem. On page 180 of...

  • in c++ Purpose: This lab will give you experience harnessing an existing backtracking algorithm for the...

    in c++ Purpose: This lab will give you experience harnessing an existing backtracking algorithm for the eight queens problem, and seeing its results displayed on your console window (that is, the location of standard output). Lab A mostly complete version of the eight queens problem has been provided for you to download. This version has the class Queens nearly completed. You are to provide missing logic for the class Queens that will enable it to create a two-dimensional array that...

  • This is my code for a TicTacToe game. However, I don't know how to write JUnit...

    This is my code for a TicTacToe game. However, I don't know how to write JUnit tests. Please help me with my JUnit Tests. I will post below what I have so far. package cs145TicTacToe; import java.util.Scanner; /** * A multiplayer Tic Tac Toe game */ public class TicTacToe {    private char currentPlayer;    private char[][] board;    private char winner;       /**    * Default constructor    * Initializes the board to be 3 by 3 and...

  • Language is C++ Basic principles and theory of structured programming in C++ by implementing the class:...

    Language is C++ Basic principles and theory of structured programming in C++ by implementing the class: Matrix Use these principles and theory to help build and manipulate instances of the class (objects), call member functions Matrix class implementation from the main function file and, in addition, the Matrix class must have its interface(Matrix.h) in a separate file from its implementation (Matrix.cpp). The code in the following files: matrix.h matrix.cpp matrixDriver.h Please use these file names exactly. Summary Create three files...

  • Concepts: multi-dimension array and the Knight's Tour Problem A chess board consists of an 8 x 8 "array" of squares: int board[ROW][COL]={0}; A knight may move perpendicular to the edges o...

    Concepts: multi-dimension array and the Knight's Tour Problem A chess board consists of an 8 x 8 "array" of squares: int board[ROW][COL]={0}; A knight may move perpendicular to the edges of the board, two squares in any of the 4 directions, then one square at right angles to the two-square move. The following lists all 8 possible moves a knight could make from board [3][3]: board[5][4] or board[5][2] or board[4][5] or board[4][1] or board[1][4] or board[1][2] or board[2][5] or board[2][1]...

  • Hello I am having trouble with a connectFour java program. this issue is in my findLocalWinner...

    Hello I am having trouble with a connectFour java program. this issue is in my findLocalWinner method, it declares a winner for horizontal wins, but not for vertical. if anyone can see what im doing wrong. public class ConnectFour { /** Number of columns on the board. */ public static final int COLUMNS = 7; /** Number of rows on the board. */ public static final int ROWS = 6; /** Character for computer player's pieces */ public static final...

  • Make sure to include: Ship.java, ShipTester.java, Location.java, LocationTester.java, Grid.java, GridTester.java, Player.java, PlayerTester.java, battleship.java. please do every...

    Make sure to include: Ship.java, ShipTester.java, Location.java, LocationTester.java, Grid.java, GridTester.java, Player.java, PlayerTester.java, battleship.java. please do every part, and include java doc and comments Create a battleship program. Include Javadoc and comments. Grade 12 level coding style using java only. You will need to create a Ship class, Location class, Grid Class, Add a ship to the Grid, Create the Player class, the Battleship class, Add at least one extension. Make sure to include the testers. Starting code/ sample/methods will be...

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