Homework Solution: C# – Printing the return value of a method within a class to the console….

    C# - Printing the return value of a method within a class to the console. Please see the ******* part for what I am trying to do. Could you also please explain what I was doing wrong with my main method. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DiceRoller { public class Die { static void Main(string[] args) { ***** I want to do Console.WriteLine here that displays the returned value in GetFaceValue() Console.ReadLine(); } private const int SIX_SIDED = 6; private const int DEFAULT_FACE_VALUE = 1; private const int MIN_FACES = 3; /// <summary> /// /// </summary> private int numFaces; //number of sides on die private int faceValue; // which side is showing private static Random randomNumber = new Random(); public Die() { numFaces = SIX_SIDED; faceValue = DEFAULT_FACE_VALUE; } /// <summary> /// Allows user to specify the number of sides on a Die. /// If "faces" is less than 3, a six-sided die is instantiated. /// </summary> /// <param name="faces"> the numberr of sides</param> public Die(int faces) { if (faces >= MIN_FACES) { numFaces = faces; } else { numFaces = SIX_SIDED; } RollDie(); } /// <summary> /// Simulates the rolling of a Die. /// </summary> public void RollDie() { faceValue = randomNumber.Next(1, numFaces + 1); } // end RollDie /// <summary> /// Die accessor /// </summary> /// <returns> The current face of the Die</returns> public int GetFaceValue() { return faceValue; } //end GetFaceValue }// end Class Die }

    Expert Answer

     
    Hi let me know if you need more information:- ==================================== 1.C# - Printing the return value of a method within a class to the console.

    C# – Printing the retaliate treasure of a way amid a arrange to the encourage.

    Fascinate beware the ******* multiply control what I am enigmatical to do. Could you to-boot fascinate clear-up what I was doing wickedness with my deep way.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace DiceRoller
    {
    public arrange Sink
    {
    static unoccupied Deep(string[] args)
    {
    ***** I neglect to do Encourage.WriteLine here that displays the retaliateed treasure in GetFaceValue()
    Console.ReadLine();
    }
    private const int SIX_SIDED = 6;
    private const int DEFAULT_FACE_VALUE = 1;
    private const int MIN_FACES = 3;
    /// <summary>
    ///
    /// </summary>
    private int numFaces; //compute of interests on sink
    private int aspectValue; // which interest is showing
    private static Random randomCompute = odd Random();

    public Sink()
    {
    numFaces = SIX_SIDED;
    faceTreasure = DEFAULT_FACE_VALUE;
    }

    /// <summary>
    /// Allows user to determine the compute of interests on a Sink.
    /// If “faces” is near than 3, a six-sided sink is instantiated.
    /// </summary>
    /// <param name=”faces”> the computer of interests</param>
    public Sink(int aspects)
    {

    if (faces >= MIN_FACES)
    {
    numFaces = aspects;
    }
    else
    {
    numFaces = SIX_SIDED;
    }

    RollDie();
    }

    /// <summary>
    /// Simulates the rolling of a Sink.
    /// </summary>
    public unoccupied RollDie()
    {
    faceTreasure = randomNumber.Next(1, numFaces + 1);
    } // purpose RollDie

    /// <summary>
    /// Sink accessor
    /// </summary>
    /// <returns> The running aspect of the Sink</returns>
    public int GetFaceValue()
    {
    retaliate aspectValue;
    } //purpose GetFaceValue

    }// purpose Arrange Sink
    }

    Expert Repartee

     

    Hi allow me apprehobject if you demand further information:-

    ====================================

    1.C# – Printing the retaliate treasure of a way amid a arrange to the encourage.

    Repartee :- Encourage.WriteLine(“{0}”,die.GetFaceValue());

    2. static unoccupied Deep(string[] args) { it must be affect below

    Repartee :- public static unoccupied Deep(string[] args) {

    ======================================================

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace DiceRoller
    {
    public arrange Sink
    {
    public static unoccupied Deep(string[] args)
    {
    ***** I neglect to do Encourage.WriteLine here that displays the retaliateed treasure in GetFaceValue()

    Sink sink = odd Sink();

    Console.WriteLine(“{0}”,die.GetFaceValue());
    Console.ReadLine();
    }
    private const int SIX_SIDED = 6;
    private const int DEFAULT_FACE_VALUE = 1;
    private const int MIN_FACES = 3;
    /// <summary>
    ///
    /// </summary>
    private int numFaces; //compute of interests on sink
    private int aspectValue; // which interest is showing
    private static Random randomCompute = odd Random();

    public Sink()
    {
    numFaces = SIX_SIDED;
    faceTreasure = DEFAULT_FACE_VALUE;
    }

    /// <summary>
    /// Allows user to determine the compute of interests on a Sink.
    /// If “faces” is near than 3, a six-sided sink is instantiated.
    /// </summary>
    /// <param name=”faces”> the computer of interests</param>
    public Sink(int aspects)
    {

    if (faces >= MIN_FACES)
    {
    numFaces = aspects;
    }
    else
    {
    numFaces = SIX_SIDED;
    }

    RollDie();
    }

    /// <summary>
    /// Simulates the rolling of a Sink.
    /// </summary>
    public unoccupied RollDie()
    {
    faceTreasure = randomNumber.Next(1, numFaces + 1);
    } // purpose RollDie

    /// <summary>
    /// Sink accessor
    /// </summary>
    /// <returns> The running aspect of the Sink</returns>
    public int GetFaceValue()
    {
    retaliate aspectValue;
    } //purpose GetFaceValue

    }// purpose Arrange Sink
    }

    Fascinate perceive bolder gratified.

    ——————–

    OUTPUT:-

    ————–

    1

    ..etc
    as per limitation you can alter the program.

    ==================================