Click here to Skip to main content
15,881,248 members
Home / Discussions / C#
   

C#

 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 2:19
professionalWes Aday27-Aug-12 2:19 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 2:26
drgsldr6927-Aug-12 2:26 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 2:54
professionalWes Aday27-Aug-12 2:54 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 3:20
drgsldr6927-Aug-12 3:20 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 3:29
professionalWes Aday27-Aug-12 3:29 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 5:29
drgsldr6927-Aug-12 5:29 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 5:34
professionalWes Aday27-Aug-12 5:34 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 5:36
drgsldr6927-Aug-12 5:36 
Ok then can you please explain what I would have to do to make that work? Or at least give me an example code that I could use to figure it out? Cause as it sits right now I am lost. Below is the entire ability class

class Abilities
{
    //Start Abilities
    //-----------------------------------------------------------------------------------------------------------------------------------
    Dice dice = new Dice();

    public void ShowAbilities(int Str, int Dex, int Con, int Int, int Wis, int Cha)
    {
        Console.WriteLine("Strength:     {0}\n", Str);
        Console.WriteLine("Dexterity:    {0}\n", Dex);
        Console.WriteLine("Constitution: {0}\n", Con);
        Console.WriteLine("Intelligence: {0}\n", Int);
        Console.WriteLine("Wisdom:       {0}\n", Wis);
        Console.WriteLine("Charisma:     {0}\n", Cha);
    }

    public void RollAbilities()
    {
        Abilities BaseClass = new Abilities();
        BaseClass.RollStr();
        BaseClass.RollDex();
        BaseClass.RollCon();
        BaseClass.RollInt();
        BaseClass.RollWis();
        BaseClass.RollCha();
    }

    public void RollStr()
    {
        Abilities BaseClass = new Abilities();
        int Str;

        Str = dice.Roll5D6();
        Console.Write("Str: {0} \n", Str);
        //Reroll the dice
        char MyChoice;
        string MyInput;
        char ReRoll = Convert.ToChar("y");

        Console.Write("Would you like to reroll this score?");
        MyInput = Console.ReadLine();
        MyChoice = Convert.ToChar(MyInput);

        if (MyInput == Convert.ToString(ReRoll))
        {
            BaseClass.RollStr();
        }

    }

    public void RollDex()
    {
        Abilities BaseClass = new Abilities();
        int Dex;

        Dex = dice.Roll5D6();
        Console.Write("Dex: {0} \n", Dex);

        //Reroll the dice
        char MyChoice;
        string MyInput;
        char ReRoll = Convert.ToChar("y");

        Console.Write("Would you like to reroll this score?");
        MyInput = Console.ReadLine();
        MyChoice = Convert.ToChar(MyInput);

        if (MyInput == Convert.ToString(ReRoll))
        {
            BaseClass.RollDex();
        }
    }

    public void RollCon()
    {
        Abilities BaseClass = new Abilities();
        int Con;

        Con = dice.Roll5D6();
        Console.Write("Con: {0} \n", Con);

        //Reroll the dice
        char MyChoice;
        string MyInput;
        char ReRoll = Convert.ToChar("y");

        Console.Write("Would you like to reroll this score?");
        MyInput = Console.ReadLine();
        MyChoice = Convert.ToChar(MyInput);

        if (MyInput == Convert.ToString(ReRoll))
        {
            BaseClass.RollCon();
        }

    }

    public void RollInt()
    {
        Abilities BaseClass = new Abilities();
        int Int;

        Int = dice.Roll5D6();
        Console.Write("Int: {0} \n", Int);

        //Reroll the dice
        char MyChoice;
        string MyInput;
        char ReRoll = Convert.ToChar("y");

        Console.Write("Would you like to reroll this score?");
        MyInput = Console.ReadLine();
        MyChoice = Convert.ToChar(MyInput);

        if (MyInput == Convert.ToString(ReRoll))
        {
            BaseClass.RollInt();
        }

    }

    public void RollWis()
    {
        Abilities BaseClass = new Abilities();
        int Wis;

        Wis = dice.Roll5D6();
        Console.Write("Wis: {0} \n", Wis);

        //Reroll the dice
        char MyChoice;
        string MyInput;
        char ReRoll = Convert.ToChar("y");

        Console.Write("Would you like to reroll this score?");
        MyInput = Console.ReadLine();
        MyChoice = Convert.ToChar(MyInput);

        if (MyInput == Convert.ToString(ReRoll))
        {
            BaseClass.RollWis();
        }

    }

    public void RollCha()
    {
        Abilities BaseClass = new Abilities();
        int Cha;

        Cha = dice.Roll5D6();
        Console.Write("Cha: {0} \n", Cha);

        //Reroll the dice
        char MyChoice;
        string MyInput;
        char ReRoll = Convert.ToChar("y");

        Console.Write("Would you like to reroll this score?");
        MyInput = Console.ReadLine();
        MyChoice = Convert.ToChar(MyInput);

        if (MyInput == Convert.ToString(ReRoll))
        {
            BaseClass.RollCha();
        }

    }


    //End Abilities
    //-----------------------------------------------------------------------------------------------------------------------------------
I was trying to pass Showabilities over to the class that holds the actual character generator which is below.
C#
public class Fighter : attributes
 {
    Abilities abilities = new Abilities();
      public void Character()
       {
          string N;
          N = base.Name();
          Console.Write("\n");
          Console.Write("Your Name is: {0} \n", N);
          abilities.ShowAbilities(Str, Dex, Con, Int, Wis, Cha);
       }

GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 5:42
professionalWes Aday27-Aug-12 5:42 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 5:45
drgsldr6927-Aug-12 5:45 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 6:02
professionalWes Aday27-Aug-12 6:02 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 6:18
drgsldr6927-Aug-12 6:18 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 6:34
professionalWes Aday27-Aug-12 6:34 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 7:54
drgsldr6927-Aug-12 7:54 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 7:58
drgsldr6927-Aug-12 7:58 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 8:15
professionalWes Aday27-Aug-12 8:15 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 13:53
drgsldr6927-Aug-12 13:53 
AnswerRe: Trouble passing variables Pin
BillWoodruff26-Aug-12 15:23
professionalBillWoodruff26-Aug-12 15:23 
GeneralRe: Trouble passing variables Pin
drgsldr6926-Aug-12 15:44
drgsldr6926-Aug-12 15:44 
QuestionDatabase Connection on Deployment Pin
SHASHANK SAGAR26-Aug-12 8:36
SHASHANK SAGAR26-Aug-12 8:36 
AnswerRe: Database Connection on Deployment Pin
Eddy Vluggen26-Aug-12 8:49
professionalEddy Vluggen26-Aug-12 8:49 
AnswerRe: Database Connection on Deployment Pin
Vijay Selvaraj26-Aug-12 21:53
Vijay Selvaraj26-Aug-12 21:53 
GeneralRe: Database Connection on Deployment Pin
SHASHANK SAGAR27-Aug-12 3:07
SHASHANK SAGAR27-Aug-12 3:07 
AnswerRe: Database Connection on Deployment Pin
Shameel27-Aug-12 5:28
professionalShameel27-Aug-12 5:28 
QuestionWhere is my System.Drawing Pin
hosseinDolat25-Aug-12 22:55
hosseinDolat25-Aug-12 22:55 

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.