Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 History { get; set; }

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

Understand the elements of a job description

Answered: 1 week ago

Question

How We Listen?

Answered: 1 week ago