Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CarGarage/CarGarage.csproj
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>
143 changes: 143 additions & 0 deletions CarGarage/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
using System;
using System.Collections.Generic;

public class Program
{
public static void Main()
{
Car blueCar = new Car("blue");
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);
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("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 static 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<Person> people;

public Car(string initialColor)
{
people = new List<Person>();
Color = initialColor;


}
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; }
}

public class Garage
{
public Car[] cars { get; private set; }

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
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This getter should not console anything to the screen.

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));
cars[i].getPeople();
}
}
return "That's all!";
}
}
}
public class Person
{

public string firstName { get; private set; }
public string lastName { get; private set; }
public Person(string firstName, string lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}

}
21 changes: 19 additions & 2 deletions FizzBuzz/FizzBuzz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}
}
}
}

122 changes: 122 additions & 0 deletions StarWars/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
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);
PrintRoster(station1);
}
private static void PrintRoster(Station station)
{

foreach (KeyValuePair<int, Ship> 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did not expect a console statement in the passengers getter.

{
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was expecting a station rooster method.

{
public string Name { get; set; }
public string Alliance { get; set; }
public int Size { get; set; }
public Dictionary<int,Ship> Docked = new Dictionary<int, Ship>();
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);
}
}
8 changes: 8 additions & 0 deletions StarWars/StarWars.csproj
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>
68 changes: 68 additions & 0 deletions TextGame/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,71 @@
using System;
<<<<<<< HEAD
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);
}


=======

namespace TextGame
{
Expand All @@ -7,6 +74,7 @@ class Program
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
>>>>>>> d2fd3277576d0b313a2a44f3bca7c718c5dd1178
}
}
}
Loading