Hi, I have three classes public class Player
, public class Computer : Player
, and public class Game
.
In Game
I have a List: public List<Player> PlayerList
and a variable Player CurrentPlayer
.
Heres what happens: when I create a new Computer()
I add it to the PlayerList
, the CurrentPlayer
acts like an Iterator and tracks the current player in the game.
Heres the Question: I want to know if(CurrentPlayer is Computer)
(this by-the-way does not work).
HuePig
0
Light Poster
Recommended Answers
Jump to PostA
Computer
is aPlayer
with some extras I assume.CurrentPlayer
is aPlayer
, not aComputer
.
Jump to PostI'm not really sure what you are after but I did some tinkering - might help, might not.
void Main() { var game = new Game(); Player dave = new Player { Name = "Dave" }; Player sarah = new Player { Name = "Sarah" }; Computer …
All 5 Replies
ddanbe
2,724
Professional Procrastinator
Featured Poster
HuePig
0
Light Poster
DaveAmour
160
Mmmmmm beer
Featured Poster
DaveAmour
160
Mmmmmm beer
Featured Poster
HuePig
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.