From 22ccbc69489756f1a828cdaaa384170c89a54656 Mon Sep 17 00:00:00 2001 From: DeMarco Date: Sat, 6 Oct 2018 11:01:55 -0500 Subject: [PATCH 01/10] finished week1 practice --- Week1-Practice/Program.cs | 51 ++++++++++++++++++++++++++++ Week1-Practice/Week1-Practice.csproj | 9 +++++ 2 files changed, 60 insertions(+) create mode 100644 Week1-Practice/Program.cs create mode 100644 Week1-Practice/Week1-Practice.csproj diff --git a/Week1-Practice/Program.cs b/Week1-Practice/Program.cs new file mode 100644 index 00000000..f5903523 --- /dev/null +++ b/Week1-Practice/Program.cs @@ -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); + + } + } + +} diff --git a/Week1-Practice/Week1-Practice.csproj b/Week1-Practice/Week1-Practice.csproj new file mode 100644 index 00000000..b8c2678e --- /dev/null +++ b/Week1-Practice/Week1-Practice.csproj @@ -0,0 +1,9 @@ + + + + Exe + netcoreapp2.1 + Week1_Practice + + + From d8271b9287dcc7b28b64eb2e2553a3a1f71b1782 Mon Sep 17 00:00:00 2001 From: DeMarco Date: Sun, 7 Oct 2018 22:18:07 -0500 Subject: [PATCH 02/10] textgame file added --- TextGame/TextGame.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 TextGame/TextGame.cs diff --git a/TextGame/TextGame.cs b/TextGame/TextGame.cs new file mode 100644 index 00000000..cb26e2c1 --- /dev/null +++ b/TextGame/TextGame.cs @@ -0,0 +1,18 @@ +musing System; +using threading; + +namespace TextGame +{ + + class Program + { + + public void Main(string[] args) + { + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Console.WriteLine("Welcome to the cavern of secrets!"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + + } + } +} \ No newline at end of file From e11262739c429c1abcd0b6091fac436f01ebbb42 Mon Sep 17 00:00:00 2001 From: DeMarco Date: Sun, 7 Oct 2018 22:22:14 -0500 Subject: [PATCH 03/10] file renamed --- TextGame/{TextGame.cs => Program.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename TextGame/{TextGame.cs => Program.cs} (94%) diff --git a/TextGame/TextGame.cs b/TextGame/Program.cs similarity index 94% rename from TextGame/TextGame.cs rename to TextGame/Program.cs index cb26e2c1..2ad6914c 100644 --- a/TextGame/TextGame.cs +++ b/TextGame/Program.cs @@ -1,5 +1,5 @@ musing System; -using threading; +// using threading; namespace TextGame { From 2efd24f79bc6e2d9e43a8d53fcb47161e25369a9 Mon Sep 17 00:00:00 2001 From: DeMarco Date: Mon, 8 Oct 2018 00:01:06 -0500 Subject: [PATCH 04/10] 1st attempt text game --- TextGame/Program.cs | 58 +++++++++++++++++++++++++++++++++++++--- TextGame/textgame.csproj | 8 ++++++ 2 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 TextGame/textgame.csproj diff --git a/TextGame/Program.cs b/TextGame/Program.cs index 2ad6914c..f36f44f5 100644 --- a/TextGame/Program.cs +++ b/TextGame/Program.cs @@ -1,5 +1,5 @@ -musing System; -// using threading; +using System; +using System.Threading; namespace TextGame { @@ -7,12 +7,62 @@ namespace TextGame class Program { - public void Main(string[] args) + 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 random = new Random(); + // int fdmg1 = Random.Next(3, 10); + // int edmg1 = Random.Next(1, 5); + Console.WriteLine("you hit a"); + Console.WriteLine("the spider hits a"); + Thread.Sleep(2000); + } + } } -} \ No newline at end of file +} diff --git a/TextGame/textgame.csproj b/TextGame/textgame.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/TextGame/textgame.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + From ff1c62b4b12f48870fcd03309b0a8c72004e15db Mon Sep 17 00:00:00 2001 From: DeMarco Date: Tue, 9 Oct 2018 22:04:21 -0500 Subject: [PATCH 05/10] updated text game --- TextGame/Program.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/TextGame/Program.cs b/TextGame/Program.cs index f36f44f5..eb04b169 100644 --- a/TextGame/Program.cs +++ b/TextGame/Program.cs @@ -54,9 +54,10 @@ static void Main(string[] args) Console.WriteLine("IF THE SPIDER HITS HIGHER THAN YOU, YOU WILL DIE"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Thread.Sleep(2000); - // Random random = new Random(); - // int fdmg1 = Random.Next(3, 10); - // int edmg1 = Random.Next(1, 5); + // 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); From ce7dd0e9888151708d3d845d7d48f042bbce5a11 Mon Sep 17 00:00:00 2001 From: DeMarco Date: Mon, 22 Oct 2018 21:53:14 -0500 Subject: [PATCH 06/10] finail fizzbuzz --- FizzBuzz/FizzBuzz.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/FizzBuzz/FizzBuzz.cs b/FizzBuzz/FizzBuzz.cs index 9246f703..b3e5bff9 100644 --- a/FizzBuzz/FizzBuzz.cs +++ b/FizzBuzz/FizzBuzz.cs @@ -6,7 +6,24 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + for ( int i = 1; i <= 100; i++ ) + { + if (i % 3 == 0 & i % 5 == 0) + { + Console.WriteLine("FizzBuzz"); + } else if (i % 5 == 0) + { + Console.WriteLine("Buzz"); + } + else if (i % 3 == 0) + { + Console.WriteLine("Fizz"); + } else{ + Console.WriteLine(i); + } + } + + } } } -} + From c4f83b13c44864682882ef15c2ca2969155ced71 Mon Sep 17 00:00:00 2001 From: DeMarco Date: Sat, 10 Nov 2018 11:14:17 -0600 Subject: [PATCH 07/10] CarGarage first commit --- CarGarage/CarGarage.csproj | 8 +++ CarGarage/Program.cs | 107 +++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 CarGarage/CarGarage.csproj create mode 100644 CarGarage/Program.cs diff --git a/CarGarage/CarGarage.csproj b/CarGarage/CarGarage.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/CarGarage/CarGarage.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/CarGarage/Program.cs b/CarGarage/Program.cs new file mode 100644 index 00000000..460c43b2 --- /dev/null +++ b/CarGarage/Program.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; + +public class Program +{ + public static void Main() + { + Car blueCar = new Car("blue"); + Garage smallGarage = new Garage(2); + + smallGarage.ParkCar(blueCar, 0); + Console.WriteLine(smallGarage.Cars); + try + { + Car car = getCar(smallGarage); + Console.WriteLine(car.Color); + }catch{ + Console.WriteLine("No car found"); + } + + + } + public Car getCar(Garage myCars) + { + string userCar = getUserCar(); + foreach (Car car in myCars.cars) + { + if (car.Color == userCar) + { + return car; + } + } + return null; + + } + +} +public class Car +{ + // List people = new List(); + + public Car(string initialColor) + { + Color = initialColor; + // Person person1 = new Person("James", "Smith"); + // Person person2 = new Person("Jane", "Ann"); + // people.Add(person1); + // people.Add(person2); + + } + + public string Color { get; private set; } +} + +public class Garage +{ + private Car[] cars; + + public Garage(int initialSize) + { + Size = initialSize; + this.cars = new Car[initialSize]; + } + + public int Size { get; private set; } + + public void ParkCar(Car car, int spot) + { + cars[spot] = car; + } + + public string Cars + { + get + { + for (int i = 0; i < cars.Length; i++) + { + if (cars[i] != null) + { + Console.WriteLine(String.Format("The {0} car is in spot {1}.", cars[i].Color, i)); + } + } + return "That's all!"; + } + } + public string getUserCar() + { + Console.WriteLine("What car would you like?"); + string carChoice = Console.ReadLine(); + return carChoice; + + } + + class Person + { + string firstName; + string lastName; + public Person(string firstName, string lastName) + { + this.firstName = firstName; + this.lastName = lastName; + } + + } +} + + From 714529a4cf99cf554769a24889de26ee57c08919 Mon Sep 17 00:00:00 2001 From: DeMarco Date: Sat, 10 Nov 2018 13:41:17 -0600 Subject: [PATCH 08/10] Final Garage program --- CarGarage/Program.cs | 98 ++++++++++++++++++++++++++++++-------------- 1 file changed, 67 insertions(+), 31 deletions(-) diff --git a/CarGarage/Program.cs b/CarGarage/Program.cs index 460c43b2..872acd17 100644 --- a/CarGarage/Program.cs +++ b/CarGarage/Program.cs @@ -6,21 +6,55 @@ public class Program public static void Main() { Car blueCar = new Car("blue"); - Garage smallGarage = new Garage(2); + Car redCar = new Car("red"); + Car greenCar = new Car("green"); + Car orangeCar = new Car("orange"); + Garage smallGarage = new Garage(4); + + Person person1 = new Person("James", "Smith"); + Person person2 = new Person("Jane", "Ann"); + Person person3 = new Person("Robert", "Class"); + Person person4 = new Person("Lisa", "George"); + + blueCar.addPerson(person1); + orangeCar.addPerson(person2); + smallGarage.ParkCar(blueCar, 0); - Console.WriteLine(smallGarage.Cars); + smallGarage.ParkCar(orangeCar,1); + smallGarage.ParkCar(redCar,2); + smallGarage.ParkCar(greenCar,3); + + + for ( int i =0; i < 1; i++){ try { - Car car = getCar(smallGarage); - Console.WriteLine(car.Color); - }catch{ + Car car = getCar(smallGarage); + + Console.WriteLine("Enter your first name:"); + string firstname = Console.ReadLine(); + Console.WriteLine("Enter your last name:"); + string lastName = Console.ReadLine(); + Person person = new Person(firstname,lastName); + car.addPerson(person); + + } + catch + { Console.WriteLine("No car found"); } + } + Console.WriteLine(smallGarage.Cars); + } + public static string getUserCar() + { + Console.WriteLine("What car would you like?"); + string carChoice = Console.ReadLine().ToLower(); + return carChoice; } - public Car getCar(Garage myCars) + public static Car getCar(Garage myCars) { string userCar = getUserCar(); foreach (Car car in myCars.cars) @@ -37,16 +71,26 @@ public Car getCar(Garage myCars) } public class Car { - // List people = new List(); - + List people; + public Car(string initialColor) { + people = new List(); Color = initialColor; - // Person person1 = new Person("James", "Smith"); - // Person person2 = new Person("Jane", "Ann"); - // people.Add(person1); - // people.Add(person2); + + } + public void addPerson(Person person) + { + people.Add(person); + + } + public void getPeople() + { + foreach (Person p in people) + { + Console.WriteLine("{0} " + "{1} ", p.firstName, p.lastName); + } } public string Color { get; private set; } @@ -54,7 +98,7 @@ public Car(string initialColor) public class Garage { - private Car[] cars; + public Car[] cars { get; private set; } public Garage(int initialSize) { @@ -78,30 +122,22 @@ public string Cars if (cars[i] != null) { Console.WriteLine(String.Format("The {0} car is in spot {1}.", cars[i].Color, i)); + cars[i].getPeople(); } } return "That's all!"; } } - public string getUserCar() - { - Console.WriteLine("What car would you like?"); - string carChoice = Console.ReadLine(); - return carChoice; +} +public class Person +{ - } - - class Person + public string firstName { get; private set; } + public string lastName { get; private set; } + public Person(string firstName, string lastName) { - string firstName; - string lastName; - public Person(string firstName, string lastName) - { - this.firstName = firstName; - this.lastName = lastName; - } - + this.firstName = firstName; + this.lastName = lastName; } -} - +} From 6406231557e9d1eff0420159fab6fcf385eba629 Mon Sep 17 00:00:00 2001 From: DeMarco Date: Sun, 11 Nov 2018 17:41:38 -0600 Subject: [PATCH 09/10] first draft StarWars --- StarWars/Program.cs | 121 +++++++++++++++++++++++++++++++++++++++ StarWars/StarWars.csproj | 8 +++ 2 files changed, 129 insertions(+) create mode 100644 StarWars/Program.cs create mode 100644 StarWars/StarWars.csproj diff --git a/StarWars/Program.cs b/StarWars/Program.cs new file mode 100644 index 00000000..708556ba --- /dev/null +++ b/StarWars/Program.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; + +public class Program +{ + public static void Main() + { + Person leia = new Person("Leia", "Organa", "Rebel"); + Person darth = new Person("Darth", "Vader", "Imperial"); + Person luke = new Person("Luke", "Skywalker", "Rebel"); + Person han = new Person("Han", "Solo", "Rebel"); + Person palp = new Person("Emporer", "Palpatine", "Imperial"); + Ship x = new Ship("xwing", "Rebel", "fighter", 2); + Ship falcon = new Ship("MilFal", "Rebel", "Smuggling", 2); + Ship tie = new Ship("TieFie", "Tie", "Fighter", 1); + Station station1 = new Station("Rebel Space Station", "Rebel", 3); + Station station2 = new Station("Death Star", "Imperial", 3); + x.EnterShip(luke, 0); + x.EnterShip(han, 1); + station1.DockShip(x, 1); + Roster(station1); + } + private static void Roster(Station station) + { + foreach (KeyValuePair ships in station.Docked) + { + Console.WriteLine("Ship {0} contains:", ships.Value.Name); + Console.WriteLine("{0}", ships.Value.Passengers); + } + } +} +class Person +{ + private string firstName; + private string lastName; + private string alliance; + public Person(string firstName, string lastName, string alliance) + { + this.firstName = firstName; + this.lastName = lastName; + this.alliance = alliance; + } + public string FullName + { + get + { + return this.firstName + " " + this.lastName; + } + set + { + string[] names = value.Split(' '); + this.firstName = names[0]; + this.lastName = names[1]; + } + } +} +class Ship +{ + private Person[] passengers; + public Ship(string name, string alliance, string type, int size) + { + this.Name = name; + this.Type = type; + this.Alliance = alliance; + this.passengers = new Person[size]; + } + public string Name + { + get; + set; + } + public string Type + { + get; + set; + } + public string Alliance + { + get; + set; + } + public string Passengers + { + get + { + foreach (var person in passengers) + { + Console.WriteLine(String.Format("{0}", person.FullName)); + } + return "That's Everybody!"; + } + } + public void EnterShip(Person person, int seat) + { + this.passengers[seat] = person; + } + public void ExitShip(int seat) + { + this.passengers[seat] = null; + } +} +class Station +{ + public string Name { get; set; } + public string Alliance { get; set; } + public int Size { get; set; } + public Dictionary Docked = new Dictionary(); + public Station(string name, string alliance, int size) + { + this.Name = name; + this.Alliance = alliance; + } + public void DockShip(Ship ship, int port) + { + Docked.Add(port, ship); + } + public void UnDockShip(Ship ship, int port) + { + Docked.Remove(port); + } +} \ No newline at end of file diff --git a/StarWars/StarWars.csproj b/StarWars/StarWars.csproj new file mode 100644 index 00000000..23df6047 --- /dev/null +++ b/StarWars/StarWars.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + From a60252cbb4d15e3f539ca1a0558e2d8422123548 Mon Sep 17 00:00:00 2001 From: DeMarco Date: Wed, 14 Nov 2018 19:59:53 -0600 Subject: [PATCH 10/10] final starwars --- StarWars/Program.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/StarWars/Program.cs b/StarWars/Program.cs index 708556ba..6ff12e47 100644 --- a/StarWars/Program.cs +++ b/StarWars/Program.cs @@ -18,10 +18,11 @@ public static void Main() x.EnterShip(luke, 0); x.EnterShip(han, 1); station1.DockShip(x, 1); - Roster(station1); + PrintRoster(station1); } - private static void Roster(Station station) + private static void PrintRoster(Station station) { + foreach (KeyValuePair ships in station.Docked) { Console.WriteLine("Ship {0} contains:", ships.Value.Name);