-
Notifications
You must be signed in to change notification settings - Fork 0
Week2 2 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Week2 2 #4
Changes from all commits
22ccbc6
d8271b9
e112627
2efd24f
ff1c62b
2feaa9e
15fd5be
379f584
be448d5
94c3d89
af637c2
d93b7b0
83026ef
a8ee8e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,57 @@ | ||
| using System; | ||
| // using System.Collections.Generic; | ||
| // using System.Linq; | ||
| using System.Text; | ||
|
|
||
| namespace PigLatin | ||
| { | ||
| class Program | ||
| { | ||
| public static void Main() | ||
| static void Main(string[] args) | ||
| { | ||
| // your code goes here | ||
|
|
||
| // leave this command at the end so your program does not close automatically | ||
| Console.ReadLine(); | ||
| } | ||
| Console.WriteLine("Enter a word"); | ||
| Console.ReadLine(); | ||
|
|
||
| public static string TranslateWord(string word) | ||
| { | ||
| // your code goes here | ||
| return word; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public String TranslateWord(string word) | ||
| { | ||
| string pigWord = ""; | ||
| string sentence = ""; | ||
| string firstLetter; | ||
| string restOfWord; | ||
| string vowels = "AEIOUaeiou"; | ||
| int letterPosition; | ||
|
|
||
| while (sentence.ToLower() != "quit") | ||
| { | ||
| Console.WriteLine("Please enter a word or sentence:"); | ||
|
|
||
| sentence = Console.ReadLine(); | ||
|
|
||
| foreach (string text in sentence.Split()) | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are only handling the case when the vowel is in the first or second position. |
||
| firstLetter = text.Substring(0, 1); | ||
| restOfWord = text.Substring(1, text.Length - 1); | ||
|
|
||
| letterPosition = vowels.IndexOf(firstLetter); | ||
|
|
||
| if (letterPosition == -1) | ||
| { | ||
| // it's a consonant | ||
| pigWord = restOfWord + firstLetter + "ay"; | ||
| } | ||
| else | ||
| { | ||
| // it's a vowel | ||
| pigWord = text + "yay"; | ||
| } // end if | ||
|
|
||
| Console.Write("{0} ", pigWord); | ||
| return word; | ||
|
|
||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,18 +8,121 @@ public static void Main() | |
| { | ||
| Console.WriteLine("Enter hand 1:"); | ||
| string hand1 = Console.ReadLine().ToLower(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont see the try/catch block anywhere. |
||
| Console.WriteLine("Enter hand 2:"); | ||
| string hand2 = Console.ReadLine().ToLower(); | ||
| Console.WriteLine(CompareHands(hand1, hand2)); | ||
| string hand2 = GetComputerHand().ToLower(); | ||
| Console.WriteLine("You choose " | ||
| + hand1 + " and the computer choose " + hand2); | ||
|
|
||
| // leave this command at the end so your program does not close automatically | ||
| Console.ReadLine(); | ||
| // Console.ReadLine(); | ||
|
|
||
| int outCome = CompareHands(hand1, hand2); | ||
| if (outCome == 0) | ||
| { | ||
| Console.WriteLine("You tied!"); | ||
| } | ||
| else if (outCome == 1) | ||
| { | ||
| Console.WriteLine("Hand 1 wins"); | ||
| } | ||
| else if (outCome == 2) | ||
| { | ||
| Console.WriteLine("Hand 2 wins"); | ||
| } else { | ||
| Console.WriteLine("Please enter a valid hand"); | ||
| Console.ReadLine(); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
| public static int CompareHands(string hand1, string hand2) | ||
| { | ||
| try | ||
| { | ||
| // Your code here | ||
| if (hand1 == hand2) | ||
| { | ||
| return 0; | ||
| } | ||
| else if (hand1 == "rock" && hand2 == "scissors") | ||
| { | ||
| return 1; | ||
| } | ||
| else if (hand1 == "rock" && hand2 == "paper") | ||
| { | ||
| return 2; | ||
| } | ||
| else if (hand1 == "scissors" && hand2 == "rock") | ||
| { | ||
| return 1; | ||
| } | ||
| else if (hand1 == "scissors" && hand2 == "paper") | ||
| { | ||
| return 1; | ||
| // } else if (hand1 == hand2) | ||
| // { | ||
| // Console.WriteLine("Tie"); | ||
| // } else if (hand1 == "Paper" && hand2 == "Paper") | ||
| // { | ||
| // Console.WriteLine("Tie"); | ||
| } | ||
| else if (hand1 == "paper" && hand2 == "scissors") | ||
| { | ||
| return 2; | ||
| } | ||
| else if (hand1 == "paper" && hand2 == "rock") | ||
| { | ||
| return 1; | ||
| } | ||
| else | ||
| { | ||
| throw new Exception("Please enter a valid hand!"); | ||
|
|
||
| } | ||
| } | ||
| catch | ||
| { | ||
| Console.WriteLine("Please enter another choice!"); | ||
| return 3; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public static string CompareHands(string hand1, string hand2) | ||
| // public static bool test() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the tests defined, but the way you implemented CompareHands, these tests would not work. |
||
| // { | ||
| // return 0; | ||
|
|
||
| // CompareHands("Paper", "Paper") == 0 && | ||
| // CompareHands("Paper", "Rock") == 1 && | ||
| // CompareHands("Paper", "Scissors") == 2 && | ||
| // CompareHands("Rock", "Paper") == 2 && | ||
| // CompareHands("Rock", "Rock") == 0 && | ||
| // CompareHands("Rock", "Scissors") == 1 && | ||
| // CompareHands("Scissors", "Paper") == 1 && | ||
| // CompareHands("Scissors", "Scissors") == 0 && | ||
| // CompareHands("Scissors", "Rock") == 2; | ||
|
|
||
|
|
||
| public static String GetComputerHand() | ||
| { | ||
| // Your code here | ||
| return hand1 + ' ' + hand2; | ||
| Random Rnd = new Random(); | ||
| int randomInt = Rnd.Next(1, 4); | ||
|
|
||
| if (randomInt == 1) | ||
| { | ||
| return "Rock"; | ||
|
|
||
| } | ||
| else if (randomInt == 2) | ||
| { | ||
| return "Paper"; | ||
| } | ||
| else | ||
| { | ||
| return "Scissors"; | ||
| } | ||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| using System; | ||
| using System.Threading; | ||
|
|
||
| namespace TextGame | ||
| { | ||
|
|
||
| class Program | ||
| { | ||
|
|
||
| static void Main(string[] args) | ||
| { | ||
| Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
| Console.WriteLine("Welcome to the cavern of secrets!"); | ||
| Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
| Thread.Sleep(1000); | ||
| Console.WriteLine("You enter a dark cavern out of curiosity. It is dark and you can only make out a small stick on the floor."); | ||
| Console.WriteLine("Do you take it? [y/n]: "); | ||
| string ch1 = Console.ReadLine(); | ||
| string ch2 = Console.ReadLine(); | ||
| string ch3 = Console.ReadLine(); | ||
|
|
||
| int stick = 0; | ||
| if (ch1 == "y") | ||
| { | ||
| Console.WriteLine("You have taken the stick!"); | ||
| Thread.Sleep(2000); | ||
| stick = 1; | ||
| } | ||
| else | ||
| { | ||
| Console.WriteLine("You did not take the stick"); | ||
| stick = 0; | ||
| Console.WriteLine("As you proceed further into the cave, you see a small glowing object"); | ||
|
|
||
| } | ||
| if (ch2 == "y") | ||
| { | ||
| Console.WriteLine("You approach the object..."); | ||
| Thread.Sleep(2000); | ||
| Console.WriteLine("As you draw closer, you begin to make out the object as an eye!"); | ||
| Thread.Sleep(2000); | ||
| Console.WriteLine("The eye belongs to a giant spider!"); | ||
| Console.WriteLine("Do you try to fight it? [Y/N]"); | ||
| } | ||
| if (ch3 == "y") | ||
| { | ||
| if (stick == 1) | ||
| Console.WriteLine("You only have a stick to fight with!"); | ||
| Console.WriteLine("You quickly jab the spider in it's eye and gain an advantage"); | ||
| Thread.Sleep(2000); | ||
| Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
| Console.WriteLine(" Fighting... "); | ||
| Console.WriteLine(" YOU MUST HIT ABOVE A 5 TO KILL THE SPIDER "); | ||
| Console.WriteLine("IF THE SPIDER HITS HIGHER THAN YOU, YOU WILL DIE"); | ||
| Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); | ||
| Thread.Sleep(2000); | ||
| // Random randomNub = new Random(); | ||
| // int fdmg1 = Random.Next(3, 11); | ||
| // int edmg1 = Random.Next(1, 6); | ||
| //the random number gen will not display properly- im getting an error message | ||
| Console.WriteLine("you hit a"); | ||
| Console.WriteLine("the spider hits a"); | ||
| Thread.Sleep(2000); | ||
| } | ||
|
|
||
|
|
||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using System; | ||
|
|
||
| namespace Week1_Practice | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| int input1 = 0; | ||
| int input2 = 0; | ||
|
|
||
| Console.WriteLine("Give me a number between 0 and 100:"); | ||
| input1 = Convert.ToInt32(Console.ReadLine()); | ||
| Console.WriteLine("Give me another number between 0 and 100:"); | ||
| input2 = Convert.ToInt32(Console.ReadLine()); | ||
|
|
||
| Console.WriteLine(input1 + input2); | ||
|
|
||
| int yardLength = 0; | ||
| int inchLength = 0; | ||
| Console.WriteLine("Give me a number of yards?"); | ||
| yardLength = Convert.ToInt32(Console.ReadLine()); | ||
| inchLength = (yardLength * 36); | ||
|
|
||
| Console.WriteLine("You have {0} inches!", inchLength); | ||
|
|
||
| bool people = true; | ||
| bool f = false; | ||
| decimal numb = 0.0M; | ||
|
|
||
|
|
||
| string firstName = "DeMarco"; | ||
| string lastName = "Spears"; | ||
| int age = 27; | ||
| string job = "Client Support Agent"; | ||
| string favoriteBand = "Beetles"; | ||
| string favoriteSportsTeam = "Golden State Warriors"; | ||
|
|
||
|
|
||
| Console.WriteLine("Give me a decimal number?"); | ||
| numb = Convert.ToDecimal(Console.ReadLine()); | ||
| Console.WriteLine(numb * numb); | ||
| Console.WriteLine("I love sports my favorite team is the {0}", favoriteSportsTeam); | ||
| Console.WriteLine("My birthday is on the forth of July, I'm {0} years old!", age); | ||
| Console.WriteLine("My favorite band of all time is the {0}!", favoriteBand); | ||
| Console.WriteLine("I work at Dell as a {0}!", job); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| <RootNamespace>Week1_Practice</RootNamespace> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| using System; | ||
|
|
||
| namespace Week2_2_Practice | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| int grade = 0; | ||
| Console.WriteLine("Please enter a number from 0 - 100:"); | ||
| String input = Console.ReadLine(); | ||
| grade = Convert.ToInt32(input); | ||
|
|
||
| if (grade >= 90){ | ||
| Console.WriteLine("You made an A!"); | ||
| } else if (grade >= 80){ | ||
| Console.WriteLine("You made a B!"); | ||
| } else if (grade >= 70){ | ||
| Console.WriteLine("You made a C!"); | ||
| } else { | ||
| Console.WriteLine("You Failed!!!"); | ||
| } | ||
|
|
||
| Console.Write("End of Program"); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| <RootNamespace>Week2_2_Practice</RootNamespace> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing the tests.