game i'm trying to make for hw

Page 1 of 1

7 Replies - 1122 Views - Last Post: 23 March 2009 - 01:59 PM Rate Topic: -----

#1 lindeum   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-February 09

game i'm trying to make for hw

Posted 22 March 2009 - 01:58 PM

Ok guys, heres my problem. For HW i'm trying to make the game mastermind using two linked lists. The game works like this: The computer randomly generates four colors out of red yellow green blue white and black. You then get 8 tries to guess the colors the computer picked in the order they were picked in. if you guess a color that matches the computer's in color and position you get a black. If you have a guess that matches the computers in color but not position you get a white. These blacks and white help you by giving you hints what the computer has compared to what you have guessed. Right now i'm trying to prompt the user for there guess and fill the answerList with their 4 guesses. I'm haveing trouble because i'm getting the syntax error:

F:\Mastermind\guess.h|14|error: ISO C++ forbids declaration of `linked_list' with no type|

Once I get started I have most of the logic thought/written out myself. I just need help setting up the linked lists and getting the rest of the structure of the program correct. Thank you for all your help. I'll be back on in about an hour to check your replies. In the meantime I have some coding to do! :blink:



HERE IS THE MAIN.CPP
#include <iostream>
#include <string>
#include <time.h>
#include "guess.h"
//#include "linked_list.h"

using namespace std;

int main()
{
	Guess MyGuess;

	INT_MAX = 6;

	srand(time(0) % INT_MAX);
	{
		int number = rand() % 6 + 1;
	}


	//Creates a list for the answer
	linked_list<char>* answerList;

	//Creates a list for your guess
	linked_list<char>* guessList;

	guess::promptGuess();

}




HERE IS THE GUESS.CPP
#include <iostream>
#include <string>
#include <time.h>
#include "guess.h"
//#include "linked_list.h"

using namespace std;

int main()
{
	Guess MyGuess;

	INT_MAX = 6;

	srand(time(0) % INT_MAX);
	{
		int number = rand() % 6 + 1;
	}


	//Creates a list for the answer
	linked_list<char>* answerList;

	//Creates a list for your guess
	linked_list<char>* guessList;

	guess::promptGuess();

}





HERE IS THE GUESS.H
#ifndef Guess_H
#define Guess_H

#include <string>
#include <iostream>

using namespace std;

class Guess
{
	public:
		Guess();
		void PromptGuess();
		linked_list<char>* GetGuess();
		//Function Description: Prompts user for their guess.
		//Parameters: None
		//Output: None

		char RandomColor();
		//Function Description: Randomly generates 4 colors
		//Parameters: None
		//Output: The color assigned to that number

		linked_list<char>* RandomSequence(int number);
		//Function Description: Randomly generates a list of chars
		//Parameters: Number of char to generate
		//Output: Linked list of randomly generated chars

		int FindBlacks(linked_list<char> &AnswerList, linked_list<char> &YourList);
		//Function Description: Compares your guess to the answer for exact matches
		//Parameters: The answer list and your list
		//Output: Number of exact matches

		int FindWhites(linked_list<char> &AnswerList, linked_list<char> &YourList);
		//Function Description: Compares your guess to the answer for similar matches
		//Parameters: The answer list and your list
		//Output: Number of similar matches

		bool Judge(linked_list<char> &AnswerList, linked_list<char> &YourList);
		//function Description: Gives the number of exact and similar matches
		//Parameters: The answer list and your list
		//Output: Returns true if you have exact matches and false if not

	private:

};

#include "guess.cpp"
#endif // GUESS_H_INCLUDED



Is This A Good Question/Topic? 0
  • +

Replies To: game i'm trying to make for hw

#2 coden4fun   User is offline

  • if(coden4fun.NotTired){ ContinueToCode(); }
  • member icon

Reputation: 30
  • View blog
  • Posts: 696
  • Joined: 27-February 09

Re: game i'm trying to make for hw

Posted 22 March 2009 - 02:03 PM

I've made that game before, but I believe as a rule on dreamincode with provided source code, or not we're not able to help you with your HW, so sorry.

Good luck though that's an incredibly addicting game.
Was This Post Helpful? 0
  • +
  • -

#3 witnessmenow   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 18-March 09

Re: game i'm trying to make for hw

Posted 22 March 2009 - 02:16 PM

Hi there,

Why do you have the linked_list header file commented out? I'm sure that is some of your probem.


View Postcoden4fun, on 22 Mar, 2009 - 01:03 PM, said:

I've made that game before, but I believe as a rule on dreamincode with provided source code, or not we're not able to help you with your HW, so sorry.

Good luck though that's an incredibly addicting game.


I obviously haven't been here long, but my understanding of the rules would be he cant come and say" I need to program mastermind, will you do it!" but can ask for help if his code isnt wokring?
Was This Post Helpful? 0
  • +
  • -

#4 lindeum   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-February 09

Re: game i'm trying to make for hw

Posted 22 March 2009 - 04:07 PM

Yea, I was of the understanding we could ask for help and ask questions but not ask for the work to be done for us.
Was This Post Helpful? 0
  • +
  • -

#5 Topher84   User is offline

  • D.I.C Regular
  • member icon

Reputation: 113
  • View blog
  • Posts: 359
  • Joined: 04-June 07

Re: game i'm trying to make for hw

Posted 23 March 2009 - 12:49 AM

Yes, you can ask for HELP with homework provided you've shown some code.

Did you try uncommenting the //#include "linked_list.h"
Was This Post Helpful? 0
  • +
  • -

#6 lindeum   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 15-February 09

Re: game i'm trying to make for hw

Posted 23 March 2009 - 04:31 AM

Yes I uncommented that line but removed it. The line was actually for a class I was going to make but didn't because it wasn't necessary. My main problem is getting two linked lists declared. I know the algorithm for comparing them but i'm not sure of the syntax since they are both going to have first, current and next pointers. I have done alot of searching on the net and through my book and everything I find shows how to add items/take items away but nothing really clearly shows how to declare the linked list! Its very frustrating when I know what to do but don't understand how to do what should be the easiest part of the assignment! Also, once they are declared and I need to compare them how do I make sure I don't get the pointers screwed up between the lists? Thanks so much for the help.
Was This Post Helpful? 0
  • +
  • -

#7 xtreampb   User is offline

  • D.I.C Regular

Reputation: 15
  • View blog
  • Posts: 345
  • Joined: 20-June 07

Re: game i'm trying to make for hw

Posted 23 March 2009 - 06:15 AM

This is completly random but try using #define ...
Was This Post Helpful? 0
  • +
  • -

#8 Hyper   User is offline

  • Banned

Reputation: 108
  • View blog
  • Posts: 2,129
  • Joined: 15-October 08

Re: game i'm trying to make for hw

Posted 23 March 2009 - 01:59 PM

Yay for macros:

[rules][/rules]

If you have a specific question and have "put fourth effort" people who know will most likely help or try to help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1