Question
I need to print some information that I have n another class in C#. How can I do that? using System; using System.Collections.Generic; using System.Text;
I need to print some information that I have n another class in C#. How can I do that?
using System; using System.Collections.Generic; using System.Text;
namespace DiceGame { public class Player { public string Name { get; set; } public int Score { get; set; } public List
public Player(RollResult History) { this.History = new List
public Player(string Name) { Name = this.Name; } } }
using System;
namespace DiceGame { public class Program { public static int numberOfDice { get; set; } public static int numberOfPlayers { get; set; }
static void Main(string[] args) { Console.WriteLine("Welcome to the Dice Game! "); var game = new DiceGame(numberOfDice);
do { Console.WriteLine("How many players will be playing?"); var input = Console.ReadLine(); numberOfPlayers = int.Parse(input); for (int i = 0; i < numberOfPlayers; i++) { Player player = new Player("Player" + i); } } while (numberOfPlayers <= 1);
do { Console.WriteLine(" How many dices do you want to play with?"); var input2 = Console.ReadLine(); numberOfDice = int.Parse(input2); } while (numberOfDice <= 2);
game.Start();
for (int i = 0; i < 6; i++) { if (RollResult.Jackpot.Equals(2)) { game.IsGameOver = true; } else { Console.WriteLine($" {Players.Name} "); //how to get the player name? game.PlayTurn(); Console.WriteLine("Your dice numbers are: "); for (int j = 0; i < numberOfDice; j ++) { Console.WriteLine(dice[j] + " "); // how to get the dice numbers? } Console.WriteLine($"Your score is: {Player.Score} "); //how to get the result? System.ReadLine(Results); //System.ReadLine so user can see results
} }
Console.WriteLine($" The game is over! The winner is {game.TheWinner()}! Winner History: {Player.History}"); //how to show the history? } } }
Everywhere in the main that I have added comments is where I can't get the variables from the other class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started