laelzio.mosca 0 Light Poster

I think I found what I`m looking for, but it`s not working how I want it to, it`s no doing anything the way I have it set up.
I put my formating function inside the convertTemp(), that`s probably not where it should be.

This is my code:

import java.text.DecimalFormat;
  
    public class Temperature
   {
      private double temp;
      private char tempScale;
   
       public Temperature()
      {
      
      }
   
       public Temperature(double t, char tempS)
      {
         setTemp (t);
         setTempScale (tempS);
      }
   
   
       void displayTemp()
      {		
      	
         if (getTempScale() == 'F')
         {
            System.out.println("The current temperature is " + getTemp() + " " + getTempScale());
         }
         else
         {
            System.out.println("Which is equivalent to " + getTemp() + " " + getTempScale());
         }
      }
   	
      DecimalFormat oneDigit = new DecimalFormat("0.0");
   
       double convertTemp()
      {
         if (tempScale == 'F')
         {
            temp = (temp - 32)* 5/9;
            tempScale = 'C';
         }
         else
         {
            temp = temp * 9 / 5 + 32;
            tempScale = 'F';
         }
      	
         oneDigit.format(temp);
      
         return 0;
      }
   
       int tempState()
      {
      
         if(getTemp() >= 212 && getTempScale() == 'F' || getTemp() >= 100 && getTempScale() == 'C')
         {
            System.out.print("Water at this temperature is a gas.\n");
         }
         else if(getTemp() >= 32 && getTempScale() == 'F' || getTemp() >= 0 && getTempScale() == 'C')
         {
            System.out.print("Water at this temperature is a liquid.\n");
         }
         else
         {
            System.out.print("Water at this temperature is solid.\n");
         }
      
         return 0;
      }
   
      
   
       void setTemp(double value)
      {
         temp = value;
      }
   
       void setTempScale(char type)
      {
         tempScale = type;
      }
   
       double getTemp()
      {
        
         return temp;
      }
   
       char getTempScale()
      {
      	
         return tempScale;
      }
   }

and …

laelzio.mosca 0 Light Poster

Hi, I`m making a temperature program, the program takes the temperature F and prints the equivalent Celcius temperature. and VS.
The temperature is a double, but I get too many numbers after the decimal poit, like( 45.67777777...) I`d like to set it to only one or two numbers after the decimal.
How do I do that, I`ve been looking in a book, but I don`t know what the method is called.

Thanks

laelzio.mosca 0 Light Poster

Hi, I want to learn about how to clean up a computer to upgrade its performance, remove viruses, troubleshoot, things like that, normal maintainance pretty much.
I`d like to know what you guys would suggest for a book, is there one that I can buy that will teach me these kinds of things.

thanks guys

laelzio.mosca 0 Light Poster

I`m trying to write a sample program in java, but the book doesn`t explain how I should write my html code to execute it, I don`t even know what I should use to write a HTML code, I looked online, but didn`t find much.

this is the java code:

import java.awt.Graphics;
import javax.swing.JApplet;

class WelcomeApplet extends JApplet
{
	public void paint (Graphics g)
	{
		super.paint (g);
		g.drawString ("Welcome to Java Programming!", 25, 25);
		
	}
}

and this is the HTML:

<html>
<applet code = "WelcomeApplet.class" width - "300" height - "45">
</applet>
</html>

Thanks

laelzio.mosca 0 Light Poster

I`m in a computer science program, just started.
I`d like to know the difference between linux and windows, which one is better, or if it`s just a personal preference?
I have never even seen how linux looks like, but I`d like to try installing it in my computer since a lot of people talk about it, and so I can get a little experience with it.
My question is: Is it good to write codes using linux?
And is it possible to have linux and windows installed in the same computer, so I can access either one when I want? ( probably not, just checking)

Thanks guys.

laelzio.mosca 0 Light Poster

I`m taking java class and I`m thinking about getting one of those mini laptops just to do my school work and be able to access the internet.

for the price and portability, I`m looking at the Acer Aspire One AO532h-2326

I`d like to get an advice from you guys. How good or bad it is?
Thanks guys

laelzio.mosca 0 Light Poster

thanks, it compiles and runs now, the problem was what you said.
Instead of the parethesis I was setting it with the equal sign.

laelzio.mosca 0 Light Poster

I`m trying to use sets and gets for a code, but it`s not compiling
I`m not sure how to set and get a String,
this is what I have so far
this is class Car

String color;
void setColor(String col)
                 
         {
              color = col;
	}   	
		
	String getColor()
	{
	   return color;
	}

This compiles, but when I call it in my testCar class I get an error
This is class testCar

Car myCar = new Car();
myCar.setColor = "Red";

I`m having an error in my class testCar, when setting the color
Thanks guys

laelzio.mosca 0 Light Poster

so, in this code:

class TestCar
{
	public static void main(String[] args)
	{
		Car myCar = new Car();
		myCar.numDoors = 4;
		myCar.numPassengers = 4;
		myCar.maxSpeed = 65;
		
		System.out.println("This is a car with 4 doors, it has three passengers and the driver.");
		myCar.reverse();
	}
}

if I the reverse() is taking an int units, and maxSpeed = units, and maxSpeed = 65, then is this the correct way to call it?
myCar.reverse(myCar.maxSpeed);

is this correct, if reverse returns a void?

laelzio.mosca 0 Light Poster

I started my java class not long ago.
I`m just creating a class car, and I`m not sure how to call a function with a return type in main, can anybody help me.

this is what I have:

class TestCar
{
	public static void main(String[] args)
	{
		Car myCar = new Car();
		myCar.numDoors = 4;
		myCar.numPassengers = 4;
		myCar.maxSpeed = 65;
		
		System.out.println("This is a car with 4 doors, it has three passengers and the driver.");
		System.out.println(myCar.reverse());
	}
}

I have a class Car with numDoors, numPassengers, maxSpeed as integers.
and then a few functions returning void, one of them is: void reverse(int units) it returns nothing but takes units, when I call it in main I get an error, I think I`m not calling it properly.

laelzio.mosca 0 Light Poster

Java is always pass-by-value. The difficult thing can be to understand that Java passes objects as references passed by value.

The value of the actual parameter is copied into the formal parameter when the procedure is invoked. Any modification of the formal parameter affects only the formal parameter and not the actual parameter.

public class Arg
{
    public static void main(String[] args)
   {
      int orig = 42;
      Arg x = new Arg();
      int y = x.go(orig);
   
      System.out.println(orig + " " + y);
   }

    int go(int arg)
   {
    	arg = 52;
      arg = arg * 2;
   
      return arg;
   }
}

you get : 42 104

so arg can change and orig can`t?

laelzio.mosca 0 Light Poster

Hi, I just started my java class a few weeks ago, I have a question if you guys can help me.
I`m learning about passing arguments, so I have this small code, it works perfect, the output is " 42 84 ", but I didn`t get it. what does it mean when they say the variables that are passed by value can`t change, if after it`s passed it can be multiplied, and changed?

I just want to understand this and be clear about it.

Here is the code:

class Arg
   {
       public static void main(String[] args)
      {
         int orig = 42;
         Arg x = new Arg();
         int y = x.go(orig);
      
         System.out.println(orig + " " + y);
      }
   
       int go(int arg)
      {
         arg = arg * 2;
      
         return arg;
      }
   }

Thanks

laelzio.mosca 0 Light Poster

I just started my Java class, and I`m trying to Install Jgrasp from http://java.sun.com/javase/downloads/index.jsp
I choose the first picture, the one that just says java, with the JDK.
But after I install it, I still can`t find it in my computer.
Can anybody help me.

Thanks

laelzio.mosca 0 Light Poster

When the processor is described like this:
Intel Core i7 820QM 1.73GHz (3.06GHz Turbo Mode, 8MB Cache) processor

which number if the most important, if it`s a 1.73Ghz what 3.06Ghz turbo mode means?

laelzio.mosca 0 Light Poster

So, the i7 is definitely a better buy?

laelzio.mosca 0 Light Poster

HI, I`m looking to buy a laptop, I currently found two different brand laptops that I`m interested in. One is a sony, the other one is dell, I`m not too concerned about the brand, but since they have different processors I need a suggestion to which one is better.

The sony is a VGN-FW590 with a Intel® Core™ 2 Duo Processor T9900 (3.06GHz) processor.

The dell is a alienware M15x with a Intel Core i7 820QM 1.73GHz (3.06GHz Turbo Mode, 8MB Cache) processor.

the difference in price is only about $100, which one would be a better buy?

Thanks guys

laelzio.mosca 0 Light Poster

I want to get a book to learn more about upgrading and repairing computers, I`d like to get a few suggestions.

Thanks

laelzio.mosca 0 Light Poster

I wrote the code in visual c++2008 but it`s nothing visual.
which file is the redistribudable file?

laelzio.mosca 0 Light Poster

I finished my tic tac toe game program, I`d like to know if anyone can tell me what I need to do in order to send the .exe file to someone and make it so the file executes without problems.

Thanks guys

laelzio.mosca 0 Light Poster

this program is blocking twice if there`s two winning possibilities, and it ends before the square are all filled
I thing the problem is in main
can you help me please

// Laelzio Mosca
// 12/09/09
// Tic Tac Toe game

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

#include <iomanip>
using std::setw;

#include <string>
using std::string;

#include <cstdlib>
using std::rand;
using std::srand;

#include <ctime>
using std::time;

//global variables
const int row = 3; //size of array
const int column = 3; // size of array
string BLANK = " ";
string ticTac[row][column];

static int nspots = 9; // number of possible spots

void ticTacToe(const string ticTacToe[][column]); //Function prototypes
void player1(string ticTacToe[][column]);
void player2(string ticTac[][column]);
void generateNumber(string ticTac[][column]);
void checkWinner(string ticTac[][column]);
void checkToBlock(string ticTac[][column]);
void checkToWin(string ticTac[][column]);

// program execution begins
int main()
{
	srand( time(0));
	int numberOfPlayers;

	string ticTac[row][column] = {{BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	cout << "Enter the number of players with a max of 2 and press enter: ";
	cin >> numberOfPlayers;
	if (numberOfPlayers == 2)
	{
		ticTacToe( ticTac ); // function call

			   while (nspots > 0) 	
				{		
					player1(ticTac);	
					checkWinner(ticTac);

					if (nspots < 0) break;
					if (nspots == 0) {
						cout << "DRAW" << endl;
						break;
					}
					player2(ticTac);

					checkWinner(ticTac);
					// the following should never happen
					if (nspots == 0) {
						cout << "DRAW" << endl;
						break;
					}
				//	cout << "nspots: " << nspots << …
laelzio.mosca 0 Light Poster

I have this tic tac toe code, it`s almost working, can anybody take a look, I think the only thing wrong is in the else statement in main, but I`m not sure, I think I need to place the checkToWin and checkToBlock functions properly in main

// Laelzio Mosca
// 12/09/09
// Tic Tac Toe game

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

#include <iomanip>
using std::setw;

#include <string>
using std::string;

#include <cstdlib>
using std::rand;
using std::srand;

#include <ctime>
using std::time;

//global variables
const int row = 3; //size of array
const int column = 3; // size of array
string BLANK = " ";
string ticTac[row][column];

static int nspots = 9; // number of possible spots

void ticTacToe(const string ticTacToe[][column]); //Function prototypes
void player1(string ticTacToe[][column]);
void player2(string ticTac[][column]);
void generateNumber(string ticTac[][column]);
void checkWinner(string ticTac[][column]);
void checkToBlock(string ticTac[][column]);
void checkTowin(string ticTac[][column]);

// program execution begins
int main()
{
	srand( time(0));
	int numberOfPlayers;

	string ticTac[row][column] = {{BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	cout << "Enter the number of players with a max of 2 and press enter: ";
	cin >> numberOfPlayers;
	if (numberOfPlayers == 2)
	{
		ticTacToe( ticTac ); // function call

			   while (nspots > 0) 	
				{		
					player1(ticTac);	
					checkWinner(ticTac);

					if (nspots < 0) break;
					if (nspots == 0) {
						cout << "DRAW" << endl;
						break;
					}
					player2(ticTac);

					checkWinner(ticTac);
					// the following should never happen
					if (nspots == 0) {
						cout << …
laelzio.mosca 0 Light Poster

Please help!

// Laelzio Mosca
// 12/09/09
// Tic Tac Toe game

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

#include <iomanip>
using std::setw;

#include <string>
using std::string;

#include <cstdlib>
using std::rand;
using std::srand;

#include <ctime>
using std::time;

//global variables
const int row = 3; //size of array
const int column = 3; // size of array
string BLANK = " ";
string ticTac[row][column];

static int nspots = 9; // number of possible spots

void ticTacToe(const string ticTacToe[][column]); //Function prototypes
void player1(string ticTacToe[][column]);
void player2(string ticTac[][column]);
void generateNumber(string ticTac[][column]);
void checkWinner(string ticTac[][column]);
void checkToWin(string ticTac[][column];

// program execution begins
int main()
{
	srand( time(0));
	int numberOfPlayers;

	string ticTac[row][column] = {{BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	cout << "Enter the number of players with a max of 2 and press enter: ";
	cin >> numberOfPlayers;
	if (numberOfPlayers == 2)
	{
		ticTacToe( ticTac ); // function call

			   while (nspots > 0) 	
				{		
					player1(ticTac);	
					checkWinner(ticTac);

					if (nspots < 0) break;
					if (nspots == 0) {
						cout << "DRAW" << endl;
						break;
					}
					player2(ticTac);

					checkWinner(ticTac);
					// the following should never happen
					if (nspots == 0) {
						cout << "DRAW" << endl;
						break;
					}
				//	cout << "nspots: " << nspots << endl;
				}
			   cout << endl;
			
			   fflush(stdin); // clear the buffer, and wait to exit.
			   cout << "\nPress enter to exit " << endl;
			   getc(stdin);
	}
	else
	{
		ticTacToe( ticTac ); // function call

			   while …
laelzio.mosca 0 Light Poster

My code works good now, but the computer plays to easy, I want to make it so the computer check to see the the computer can win, if yes than mark that spot, if not, check to see if player can win, and check the box to block it , if if neither of the options are true, then call the function to generate a random number.
I don`t know how to check for "X", I have to check rows, columns, and diagonal, I starter a for loop, I don`t know if its right, and if it is, I don`t know how to proceed.

please help me

the variable nx is initialized to 0 and it mean number of X`s.
row and column =3;

void checkToWin(string ticTac[][column]
{
	int nx = 0;
	for (int i = 0; i < row; i++)
	{
		for(int j = 0; j < column; j++)
		{
			if (ticTac[][])= "X";
			nx++;
			
		}

	}
}
laelzio.mosca 0 Light Poster

my code is working good, but I`d like to make the computer play a little harder, right now it`s only generating random numbers to fill in the empty slots, I`d like to check rows and colomns first to see if the computer can win, and mark the winning square, if computer can`t win then check to see is player one can win, if so, check the square so the player can`t win, if neither one can win, then generate a random square, I`m not sure how to do that, I just started my checkToWin() function, but I`m not sure how to check every row, every column, and across, this is what I started

void checkToWin(string ticTac[][column]
{
	for (int i = 0, i < row; i++)
	{
		for(int j = 0; j < column; j++)

	}
}
laelzio.mosca 0 Light Poster

I`m just about done with this code, all I need to do is print out who won, right now it only prints " You are the winner!" but I don`t know what to do to print who is the winner, player1, player 2, or the computer.

can anyone help me please?

// Laelzio Mosca
// 12/09/09
// Tic Tac Toe game

#include <iostream>
using std::cout;
using std::cin;
using std::endl;

#include <iomanip>
using std::setw;

#include <string>
using std::string;

#include <cstdlib>
using std::rand;
using std::srand;

#include <ctime>
using std::time;

//global variables
const int row = 3; //size of array
const int column = 3; // size of array
string BLANK = " ";
string ticTac[row][column];

static int nspots = 9; // number of possible spots

void ticTacToe(const string ticTacToe[][column]); //Function prototypes
void player1(string ticTacToe[][column]);
void player2(string ticTac[][column]);
void generateNumber(string ticTac[][column]);
void checkWinner(string ticTac[][column]);

// program execution begins
int main()
{
	srand( time(0));
	int numberOfPlayers;

	string ticTac[row][column] = {{BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	cout << "Enter the number of players with a max of 2 and press enter: ";
	cin >> numberOfPlayers;
	if (numberOfPlayers == 2)
	{
		ticTacToe( ticTac ); // function call

			   while (nspots > 0) 	
				{		
					player1(ticTac);	
					checkWinner(ticTac);

					if (nspots < 0) break;
					if (nspots == 0) {
						cout << "DRAW" << endl;
						break;
					}
					player2(ticTac);

					checkWinner(ticTac);
					// the following should never happen
					if (nspots == 0) {
						cout << …
laelzio.mosca 0 Light Poster

This code is working pretty good now, but the problem is that when the player chooses to play against the computer he has to press 1, so even though I using srand() to generate the numbers, 1 is always the seed, and it puts an "O" in the boxes in the same order everytime the program runs.

this is my generateNumber() function:

{

	int a; // number 1
	int b; // number 2
	string gn = "O";
	
	
		a = (rand() % 3); // generate number 1
		b = (rand() % 3); // generate number 2

		if (ticTac[a][b] != BLANK)
		{
			generateNumber(ticTac);
		}
		else
		{
			ticTac[a][b] = gn;	
		}
	nspots--;
	ticTacToe( ticTac );
}
laelzio.mosca 0 Light Poster

oh, so in order to get numbers from 0 to 2 all I need is a = (rand() % 3) ?

laelzio.mosca 0 Light Poster

I trying to add a function generateNumber() so the computer can play after player1(), I just started the function, but there`s something wrong, my program breaks everytime I choose one player.
This is What I added in my code:

void generateNumber(string ticTac[][column])
{

	int a; // generate number 1
	int b;// generate number 2
	string gn = "O";
	
	while (nspots > 0)
	{
		a = (rand() % 3) - 1; 
		b = (rand() % 3) - 1; 

		if (ticTac[a][b] != BLANK)
		{
			generateNumber(ticTac);
		}
		else
			ticTac[a][b] = gn;	
	}
	nspots--;
	ticTacToe( ticTac );
}

and my main is now like this:

int main()
{
	int numberOfPlayers;

	string ticTac[row][column] = {{BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	cout << "Enter the number of players with a max of 2 and press enter: ";
	cin >> numberOfPlayers;
	if (numberOfPlayers == 2)
	{
		ticTacToe( ticTac ); // function call

			   while (nspots > 0) 	
				{		
					player1(ticTac);	
					checkWinner(ticTac);

					if (nspots < 0) break;
					if (nspots == 0) {
						cout << "DRAW" << endl;
						break;
					}
					player2(ticTac);

					checkWinner(ticTac);
					// the following should never happen
					if (nspots == 0) {
						cout << "DRAW" << endl;
						break;
					}
				//	cout << "nspots: " << nspots << endl;
				}
			   cout << endl;
			
			   fflush(stdin); // clear the buffer, and wait to exit.
			   cout << "\nPress enter to exit " << endl;
			   getc(stdin);
	}
	else
	{
		ticTacToe( ticTac ); // function …
laelzio.mosca 0 Light Poster

I have this code for a tic tac toe game, everything works fine, but only two player can play, I`d like to make it so the user can enter the number of players, and if there`s only one player, the user can play agains the computer, how do I get the computer to fill in a box after each time the user plays?

this is the code I have right now.

// Laelzio Mosca
// 12/09/09
// Tic Tac Toe game

#include <iostream>
#include <iomanip>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;

using std::setw;

//global variables
const int row = 3; //size of array
const int column = 3; // size of array
string BLANK = " ";
string ticTac[row][column];

static int nspots = 9; // number of possible spots

void ticTacToe(const string ticTacToe[][column]); //Function prototypes
void player1(string ticTacToe[][column]);
void player2(string ticTac[][column]);
void checkWinner(string ticTac[][column]);

// program execution begins
int main()
{
	string ticTac[row][column] = {{BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	ticTacToe( ticTac ); // function call

		   while (nspots > 0) 	
			{		
				player1(ticTac);	
				checkWinner(ticTac);

				if (nspots < 0) break;
				if (nspots == 0) {
					cout << "DRAW" << endl;
				    break;
				}
				player2(ticTac);

				checkWinner(ticTac);
				// the following should never happen
				if (nspots == 0) {
					cout << "DRAW" << endl;
				    break;
				}
			//	cout << "nspots: " << nspots << endl;
			}
		   cout << endl;
		
		   fflush(stdin); // clear …
laelzio.mosca 0 Light Poster

is my hour initialized correctly? because I now changed ovenTime = hour - cookTime; to ovenTime = 14 - cookTime; and it works fine

laelzio.mosca 0 Light Poster

I changed it to double, I tried using the weight as 10lb, and it gave me an ovenTime of -2

laelzio.mosca 0 Light Poster

dinner is supposed to be at 2pm, that`s why int hour =14, oven time is the time the turkey should go in the oven, so i`m trying to get the dinner time which is 14(hour) and subtract the cookTime from it, which is the amount of time it`s gonna take to cook, I thought that would give me the right time to put the turkey in the oven, but I did all the mall on the calculator, and everything is right, exept the ovenTime, it`s giving me crazy numbers, depending on the size of the turkey it even gives me a negative number

laelzio.mosca 0 Light Poster

Can someone help me please?

I have to do this turkey project, everything is working ok, exept for my oven time.
when it prints this line:

cout << "Put the turkey in the oven on the " << startThawDay + howLongToThaw <<"th " << " at " << ovenTime <<" o`clock." << endl;

the ovenTime is never right, I can`t find out where it`s wrong.

this is the whole code

#include<iostream>
#include<iomanip>
#include<string>

using std::setprecision;


using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::string;
double turkey();
int sweetPotatoes();
int pies();
//int thanksgivingTime(int turkeyTotalDays);


int main()
{
	//int turkeyTotalDays;
	cout << "This program will help you get your food ready thanksgiving dinner on time. " << endl << endl;
	turkey();
	sweetPotatoes();
	pies();
	cout << "Your dinner will be all ready at 2pm on thanksgiving day if you follow these instructions.";
	cout << endl << endl << "Happy Thanksgiving!" << endl;
	//thanksgivingTime(turkeyTotalDays);

	return 0;
}

double turkey()
{
	int day = 26;
	int hour = 14;
	int min = 00;
	double weightOfTurkey;
	int thawTime;
	int cookTime;
	int turkeyTotal;
	int turkeyTotalDays;
	int turkeyHour;
	int startThawDay;
	int howLongToThaw;
	int ovenTime;
	string standardTime;
	string am = "am";
	string pm = "pm";

	cout << "Enter the weight of you turkey in lbs: ";
	cin >> weightOfTurkey;
	thawTime = weightOfTurkey * 6;
	cookTime = (weightOfTurkey / 3) * .75;
	turkeyTotal = (((thawTime + cookTime)* 60)+20)/60;
	turkeyTotalDays = turkeyTotal / 24;
	turkeyHour = turkeyTotal % 24;
	startThawDay = day - turkeyTotalDays;
	hour …
laelzio.mosca 0 Light Poster

I didn`t get it, this is what I did, I don`t think this is what you meant

for (int i = 0; i = row; i++)
	{
		for (int j = 0; j = column; j++)
		{
		   while(ticTac[row][column] != BLANK) 	
			{		
				player1(ticTac);		
				player2(ticTac);	
			}			
		cout << endl;
		 break;
		}
	}

it`s doing the same thing

laelzio.mosca 0 Light Poster

I have this code for a tic tac toe game, it`s not done yet, and what I have done isn`t working like I want it to.
The screan prints and promps player 1 and 2 for inputs one at a time, but my while loop in main is probably wrong, the loop continues even after the grid if fool of X and O, I want the program to end when it`s done, and then I`ll finish my checkWinner function.
somebody told me to change my functions to a bool, but I`m not sure how to do that.

Can anybody help me?

#include <iostream>
#include <iomanip>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;

using std::setw;

//global variables
const int row = 3; //size of array
const int column = 3; // size of array
string BLANK = " ";
string ticTac[row][column];

void ticTacToe(const string ticTacToe[][column]); //Function prototypes
void player1(string ticTacToe[][column]);
void player2(string ticTac[][column]);
void checkWinner(string ticTac[][column]);

// program execution begins
int main()
{
	string ticTac[row][column] = {{BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	ticTacToe( ticTac ); // function call
	while(ticTac[row][column] != BLANK) 	
	{		
		player1(ticTac);		
		player2(ticTac);	
	}			
		cout << endl; 
	

	return 0;
}

//Function ticTacToe
void ticTacToe(const string ticTacToe[][column])
{
	cout << setw(5)<<"|"<<setw(5)<< "|" <<endl;

	//for loop-continuation condition and increment
	for (int i = 0; i < row; i ++)
	{
		for (int j = 0; j < …
laelzio.mosca 0 Light Poster

This is the code I got now, the last function if commented out because it`s not done yet, I want to get what ever is in main working properly before I finish the checkWinner function, the problem now is that it continues to loop even when the grid is full of "X and "O", I want it to jump out of the loop and end once it`s full.

can you help me

#include <iostream>
#include <iomanip>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;

using std::setw;

//global variables
const int row = 3; //size of array
const int column = 3; // size of array
string BLANK = " ";
string ticTac[row][column];

void ticTacToe(const string ticTacToe[][column]); //Function prototypes
void player1(string ticTacToe[][column]);
void player2(string ticTac[][column]);
void checkWinner(string ticTac[][column]);

// program execution begins
int main()
{
	string ticTac[row][column] = {{BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	ticTacToe( ticTac ); // function call
	while (ticTac[row][column] != BLANK) 	
	{		
		player1(ticTac);		
		player2(ticTac);	
	}			
		cout << endl; 
	

	return 0;
}

//Function ticTacToe
void ticTacToe(const string ticTacToe[][column])
{
	cout << setw(5)<<"|"<<setw(5)<< "|" <<endl;

	//for loop-continuation condition and increment
	for (int i = 0; i < row; i ++)
	{
		for (int j = 0; j < column; j++)
			//check to output '|' only in between the numbers, not at the end
			if ( j < column - 1)
			{
				cout << setw(3)<< ticTacToe[i][j] << setw(2)<<"|";
			} …
laelzio.mosca 0 Light Poster

I did that in the beginning of the code:
string BLANK = " ";

I initialized every string BLANK to " "

laelzio.mosca 0 Light Poster

I want to call functions player1()and player2() until ticTac[][] has at least one BLANK spot.
can anybody help me, this is not working

int main()
{
	string ticTac[row][column] = {{BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}, {BLANK,BLANK,BLANK}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	ticTacToe( ticTac ); // function call
	if (ticTac[row][column] = BLANK) 
	{
		player1(ticTac);
		player2(ticTac);
	}
	else
		cout << endl;
	

	return 0;
}

when I compile this program I have the following error message:

Error 1 error C2451: conditional expression of type 'std::basic_string<_Elem,_Traits,_Ax>' is illegal c:\documents and settings\fernandos computer\desktop\tic_tac\tic_tac\tic_tac.cpp 28

laelzio.mosca 0 Light Poster

I changed my code a little, instead of numbers i have the same string arrays, but they are BLANK, and i have a global variable string BLANK initialized to " "( a blank space ), so my board doesn't have any numbers.

Then I promp the user for coordinates, and store the coordinates in x and y, but when I call the function in main I get an error.

this is the function where I promp the user for input:

void player1()
{
    int x = 0;
    int y = 0;
    string p1 = "X";

    cout << "Player one can enter your coordinates for X." << endl;
        cin >> x >> y;
        if (ticTac[x][y] != BLANK)
        {
            cout << "That spot is taken." << "\nEnter different coordinates for X." << endl;
            player1();
        }
        else
            ticTac[x][y] = p1;
}

in main I call it like this:

player1();

but I get an error:

Error   1   error C2064: term does not evaluate to a function taking 0 arguments    c:\documents and settings\fernandos computer\desktop\tic_tac\tic_tac\tic_tac.cpp    29

can you help me with that

laelzio.mosca 0 Light Poster

what's the problem?

there`s no problem with this code, but I don`t know how to go any further, I`d like to get an Idea on how to get the user`s input and change the number in the grid to an "X" if it`s player1, or "O" if player2.
I`m just a biginner, I`m not sure how to do that, I was thinking on seting a switch statement, but it seems like I can`t do that since I have the number stored in the array.
I`ll be glad if you can help me

laelzio.mosca 0 Light Poster

I`m trying to program this tic tac toe game, I have the screan printing like I want it to, but I don`t know how to take the user`s input and change the numbers in the array to an "X" or "O" depending on the user`s input, and upgrade the grid, I want to have player1, and player2, "X" for player1 and "O" for player two.

Can anybody help me?

#include <iostream>
#include <iomanip>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;

using std::setw;

//global variables
const int row = 3; //size of array
const int column = 3; // size of array

void ticTacToe(const string ticTacToe[][column]); //Function prototypes

// program execution begins
int main()
{
	int player1;
	int player2;
	string ticTac[row][column] = {{"1","2","3"}, {"4","5","6"}, {"7","8","9"}}; //number display for rows and columns 
	cout << "Welcome to the tic tac toe game "<<endl << endl; // welcome message
	ticTacToe( ticTac ); // function call

	return 0;
}

//Function ticTacToe
void ticTacToe(const string ticTacToe[][column])
{
	cout << setw(5)<<"|"<<setw(5)<< "|" <<endl;

	//for loop-continuation condition and increment
	for (int i = 0; i <row; i ++)
	{
		for (int j = 0; j < column; j++)
			//check to output '|' only in between the numbers, not at the end
			if ( j < column - 1)
			{
				cout << setw(3)<< ticTacToe[i][j] << setw(2)<<"|";
			}
			else					
				cout << setw(3)<<ticTacToe[i][j];
							
			cout << endl;

			// check to make sure the horizontal line in only printed in between
			// the 3 rows, not on the …