Click here to Skip to main content
15,884,473 members
Home / Discussions / C#
   

C#

 
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 
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 
See if this makes any more sense. I did not compile this as I cannot. But should get you closer. Pay attention to the comments.
class Abilities
 {
     private int Str;
     private int Intelligence;
     private int Dexterity;


     // OR
     // public int Strength {get; set; } this is a property

     Dice dice = new Dice();

     public void ShowAbilities()
     {
         Console.WriteLine("Strength:     {0}\n", Str); // <- {0} makes no sense here.
         // Console.WriteLine(string.Format("Strength:     {0}\n", Strength")); Using a property
         Console.WriteLine(string.Format("Dexterity:    {0}\n", Dexterity));
         //Console.WriteLine("Constitution: {0}\n", Con);
         Console.WriteLine("Intelligence: {0}\n", Intelligence);
         //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();
         Str = dice.Roll5D6();
         // Or
         //Strength = 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();

         Dexterity = 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();

         Intelligence = 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();
         }

     }

Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

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 
AnswerRe: Where is my System.Drawing Pin
Richard MacCutchan25-Aug-12 23:02
mveRichard MacCutchan25-Aug-12 23:02 
AnswerRe: Where is my System.Drawing Pin
Eddy Vluggen25-Aug-12 23:32
professionalEddy Vluggen25-Aug-12 23:32 
GeneralRe: Where is my System.Drawing Pin
hosseinDolat26-Aug-12 0:04
hosseinDolat26-Aug-12 0:04 
QuestionAnother textbox question [SOLVED] Pin
Diego Carrion25-Aug-12 22:25
Diego Carrion25-Aug-12 22:25 
AnswerRe: Another textbox question Pin
OriginalGriff25-Aug-12 22:35
mveOriginalGriff25-Aug-12 22:35 

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.