Click here to Skip to main content
15,888,102 members
Home / Discussions / C#
   

C#

 
GeneralRe: Dynamic Casting (Runtime) Pin
Christian Graus10-Feb-03 19:03
protectorChristian Graus10-Feb-03 19:03 
GeneralRe: Dynamic Casting (Runtime) Pin
David Stone10-Feb-03 19:10
sitebuilderDavid Stone10-Feb-03 19:10 
GeneralRe: Dynamic Casting (Runtime) Pin
Anonymous10-Feb-03 17:17
Anonymous10-Feb-03 17:17 
GeneralRe: Dynamic Casting (Runtime) Pin
mgarwood11-Feb-03 2:36
mgarwood11-Feb-03 2:36 
GeneralRe: Dynamic Casting (Runtime) Pin
David Stone11-Feb-03 3:26
sitebuilderDavid Stone11-Feb-03 3:26 
GeneralRe: Dynamic Casting (Runtime) Pin
leppie11-Feb-03 7:30
leppie11-Feb-03 7:30 
GeneralRe: Dynamic Casting (Runtime) Pin
mgarwood11-Feb-03 9:18
mgarwood11-Feb-03 9:18 
General#iclude problems Pin
mehere10-Feb-03 14:51
mehere10-Feb-03 14:51 
hello to list

any assistance much appreciated.

i apologise if this message loads slowly (received a warning when i sent). i live way out back, very slow connection, and i get email longer than this no problem)

why did the one project i did compile include syntax
different to the text book example? (staugaard, jr. structured and object oriented techniques, 2nd edition)

using borland 5.5.1 free command line tools with a command promt screen setup for me be a student list advisor so i type in 'complink <filename> to compile. i don't want to bother him further on this matter. couldn't figure out how to get a project to compile with borland 4.5, but have succedded in getting one to run with 5.5.1. i thought all i would have to do is use the same #include, #endif, etc, and all would be well. i think the enum is wrecking things in some small part, i can't find any information to show me rules for using enum's in structs. this code is probably a bit cut up by now.

you may have to fix the word wrap
you may assume i am rather green at this
/* *************************************** */
/* Yahtzee header file: */

#ifndef YATZ_H
#define YATZ_H

struct Play
{
private:

public:

int Score[ScoreMax+1];
int Dice[DiceMax+1];

void DisplayScoreCat(ScoreCat Cat);
void DisplayDice();
void Throw();
void Initialise();
};
#endif

/* *****************************************8 */


/* main file */



#include <iostream>
#include <iomanip>
#include <stdlib>
#include <time>

using namespace std;

#include "Yahzt.h"


const int ScoreMax=17;
const int DiceMax=5;

int main()
{
enum ScoreCat {Ones, Twos, Threes,
Fours, Fives, Sixes,
Three_of_a_Kind, Four_of_a_Kind, Full_House, Small_Straight,
Large_Straight, Yahtzee, Chance, Bonus, Upper_Total, Lower_Total,
Grand_Total};

ScoreCat Cat;

Play Game; // declare Game object

Game.Initialise();

time_t t;
srand((unsigned) time(&t));

cout<<"\n\n\t\tYatsee Game "
<<"\t\tScoring Catagories \n\n";

for(Cat = Ones; Cat <= Full_House; Cat =(ScoreCat) (Cat+1))
{
cout<<"\t\t"<<(Cat+1);
Game.DisplayScoreCat(Cat);
cout<<"-"<<Game.Score[Cat];

if(Cat<=3)
{

cout<<"\t"<<(Cat +10);
}
if(Cat<=7 )
{
Game.DisplayScoreCat(Cat+9);

cout<<"-"<<Game.Score[Cat+9];
}
cout<<endl;
}//end for

cout<<"\n\n";

Game.Throw();
Game.DisplayDice();

}

#include "Yahtz.cpp"

/* ***************************************** */

/* function file */


#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;

#include "Yahtz.h"


void Play::DisplayScoreCat(ScoreCat Cat)
{
switch(Cat)
{
case Ones: cout<<setw(18)<< "Ones"; break;
case Twos: cout<<setw(18)<< "Twos"; break;
case Threes: cout<< setw(18)<< "Thees"; break;
case Fours: cout<< setw(18)<< "Fours"; break;
case Fives: cout<< setw(18)<< "Fives"; break;
case Sixes: cout<< setw(18)<< "Sixes"; break;
case Three_of_a_Kind: cout<< setw(18)<< "3 of a Kind"; break;
case Four_of_a_Kind: cout<< setw(18)<< "4 of a Kind"; break;
case Full_House: cout<< setw(18)<< "Full House"; break;
case Small_Straight: cout<< setw(18)<< "Small Straight"; break;
case Large_Straight: cout<< setw(18)<< "Large straight"; break;
case Yahtzee: cout<< setw(18)<< "Yahtzee"; break;
case Chance: cout<< setw(18)<< "Chance"; break;
case Bonus: cout<< setw(23)<< "Bonus"; break;
case Upper_Total: cout<< setw(23)<< "Upper Total"; break;
case Lower_Total: cout<< setw(23)<< "Lower Total"; break;
case Grand_Total: cout<< setw(23)<< "Grand Total"; break;


cout<<"\t\tUnknown day"; break;
}

}



void Play::DisplayDice()
{
cout<<"\tThe 5 dice are :\n";
for(int i=0;i<5;i++)
{
cout<<Dice[i];
}

char console[4] [42]=
{
" 1 2 3 4 5 \n",
"----- ----- ----- ----- -----\n",
"| | | | | | | | | |\n",
"----- ----- ----- ----- -----\n"
};
for(int i=0; i<4; i++)
{
for(int j=0; j <42; j++)
{
if(j==0)
cout<<"\t\t";

if(j==2&&i==2)
{
console[i][j]=Dice[0];
}
if(j==11&&i==2)
{
console[i][j]=Dice[1];
}
if(j==20&&i==2)
{
console[i][j]=Dice[2];
}
if(j==29&&i==2)
{
console[i][j]=Dice[3];
}
if(j==38&&i==2)
{
console[i][j]=Dice[4];
}
cout<<console[i][j];
}
}
}


void Play::Throw()
{
for(int i=0; i<5; i++)
{
Dice[i]=(1+rand()%6);
}
}

void Play::Initialise()
{
for(int i=0; i<ScoreMax; i++)
{
Score[i]=0;
}
for(int i=0; i<DiceMax; i++)
{
Dice [i]=0;
}
}

/* **********************************************

error messages generated:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
Yahtzmain.cpp:
Error E2209 Yahtzmain.cpp 12: Unable to open include file 'Yahzt.h'
Error E2451 Yahtzmain.cpp 27: Undefined symbol 'Play' in function main()
Error E2379 Yahtzmain.cpp 27: Statement missing ; in function main()
Error E2451 Yahtzmain.cpp 29: Undefined symbol 'Game' in function main()
Error E2293 Yahtz.h 15: ) expected
Error E2147 Yahtz.cpp 12: 'ScoreCat' cannot start a parameter declaration
Error E2316 Yahtz.cpp 13: 'Play::DisplayScoreCat(int)' is not a member of 'Play'
Error E2206 Yahtz.cpp 35: Illegal character '\' (0x5c)
Error E2206 Yahtz.cpp 35: Illegal character '\' (0x5c)
*** 9 errors in Compile ***


*/


GeneralRe: #iclude problems Pin
Christian Graus10-Feb-03 15:17
protectorChristian Graus10-Feb-03 15:17 
GeneralRe: #iclude problems Pin
mehere10-Feb-03 18:08
mehere10-Feb-03 18:08 
GeneralRe: #iclude problems Pin
David Stone10-Feb-03 18:22
sitebuilderDavid Stone10-Feb-03 18:22 
GeneralRe: #iclude problems Pin
Stephane Rodriguez.10-Feb-03 19:01
Stephane Rodriguez.10-Feb-03 19:01 
GeneralRe: #iclude problems Pin
David Stone10-Feb-03 19:04
sitebuilderDavid Stone10-Feb-03 19:04 
GeneralRe: #iclude problems Pin
mehere10-Feb-03 22:43
mehere10-Feb-03 22:43 
GeneralRegex problem across muliple lines Pin
Giles10-Feb-03 12:06
Giles10-Feb-03 12:06 
GeneralRe: Regex problem across muliple lines Pin
Anonymous10-Feb-03 17:14
Anonymous10-Feb-03 17:14 
Generalsubclassed controls Pin
vlusardi10-Feb-03 9:55
vlusardi10-Feb-03 9:55 
GeneralRe: subclassed controls Pin
leppie10-Feb-03 10:10
leppie10-Feb-03 10:10 
GeneralRe: subclassed controls Pin
vlusardi10-Feb-03 11:06
vlusardi10-Feb-03 11:06 
GeneralCOM+ in .NET::C# & DLLs Pin
sss_dr10-Feb-03 8:23
sss_dr10-Feb-03 8:23 
GeneralOwner Draw... Pin
Yuval Kaplan10-Feb-03 1:56
Yuval Kaplan10-Feb-03 1:56 
GeneralRe: Owner Draw... Pin
TigerNinja_10-Feb-03 2:40
TigerNinja_10-Feb-03 2:40 
GeneralRe: Owner Draw... Pin
Yuval Kaplan10-Feb-03 6:08
Yuval Kaplan10-Feb-03 6:08 
GeneralWebBrowser API problem. Pin
GriffonRL10-Feb-03 1:49
GriffonRL10-Feb-03 1:49 
GeneralRe: WebBrowser API problem (repost because first URL translated). Pin
GriffonRL10-Feb-03 1:54
GriffonRL10-Feb-03 1:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.