diff --git a/OOP1/.vscode/launch.json b/OOP1/.vscode/launch.json new file mode 100644 index 00000000..013a4f80 --- /dev/null +++ b/OOP1/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/CarGarage/bin/Debug/netcoreapp2.2/CarGarage.dll", + "args": [], + "cwd": "${workspaceFolder}/CarGarage", + // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window + "console": "internalConsole", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ,] +} \ No newline at end of file diff --git a/OOP1/.vscode/tasks.json b/OOP1/.vscode/tasks.json new file mode 100644 index 00000000..23048382 --- /dev/null +++ b/OOP1/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/CarGarage/CarGarage.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/OOP1/CarGarage/.vscode/launch.json b/OOP1/CarGarage/.vscode/launch.json new file mode 100644 index 00000000..ce905be5 --- /dev/null +++ b/OOP1/CarGarage/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/CarGarage.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window + "console": "internalConsole", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ,] +} \ No newline at end of file diff --git a/OOP1/CarGarage/.vscode/tasks.json b/OOP1/CarGarage/.vscode/tasks.json new file mode 100644 index 00000000..02719807 --- /dev/null +++ b/OOP1/CarGarage/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/CarGarage.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/OOP1/CarGarage/CarGarage.csproj b/OOP1/CarGarage/CarGarage.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/OOP1/CarGarage/CarGarage.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/OOP1/CarGarage/Program.cs b/OOP1/CarGarage/Program.cs new file mode 100644 index 00000000..947e944b --- /dev/null +++ b/OOP1/CarGarage/Program.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; + +namespace OOP1 +{ + public class Program + { + public static void Main() + { + Garage smallGarage = new Garage(2); + Car blueCar = new Car("blue"); + Person person1 = new Person("Sammy Boi"); + Person person2 = new Person("Less cool person"); + blueCar.addPerson(person1, 0); + blueCar.addPerson(person2, 1); + smallGarage.ParkCar(blueCar, 0); + Console.WriteLine(smallGarage.Cars); + } + } + + public class Car + { + public Car(string initialColor) + { + Color = initialColor; + this.passengers = new List(); + } + public string Color { get; private set; } + public List passengers; + public void addPerson(Person passenger, int spot) + { + passengers.Add(passenger); + } + + public string Passengers + { + get + { + string passengerNames = ""; + for (int i = 0; i < passengers.Count; i++) + { + if (passengers[i] != null) + { + passengerNames += passengers[i].Name + " "; + } + } + return passengerNames; + } + } + } + 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} and the people in that car are: {2}", cars[i].Color, i, cars[i].Passengers)); + } + } + return "That's all!"; + + } + } + } + + public class Person + { + public Person(string initialName) + { + Name = initialName; + } + public string Name { get; private set; } + } +} \ No newline at end of file diff --git a/OOP1/Rainforest/Program.cs b/OOP1/Rainforest/Program.cs new file mode 100644 index 00000000..e0ef01f8 --- /dev/null +++ b/OOP1/Rainforest/Program.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; + + +namespace Rainforest +{ + class Program + { + static void Main(string[] args) + { + Company rainForest = new Company("RainForest"); + Warehouse w1 = new Warehouse("Austin", 10); + Warehouse w2 = new Warehouse("Houston", 15); + rainForest.Warehouses.Add(w1); + rainForest.Warehouses.Add(w2); + Container austin1 = new Container("Austin-1", 3, 0); + Container austin2 = new Container("Austin-2", 3, 1); + Container houston1 = new Container("Houston-1", 3, 2); + Container houston2 = new Container("Houston-2", 3, 3); + w1.Containers.Add(austin1); + w1.Containers.Add(austin2); + w2.Containers.Add(houston1); + w2.Containers.Add(houston2); + Item bananas = new Item("Bananas", 2.99); + Item apples = new Item("Apples", 1.50); + Item watermelon = new Item("Walermelon", 4.99); + Item grapes = new Item("grapes", 1.99); + austin1.Items.Add(bananas); + austin2.Items.Add(apples); + houston1.Items.Add(watermelon); + houston2.Items.Add(grapes); + Dictionary index = new Dictionary(); + + System.Console.WriteLine(String.Format("{0} Company Manifest:", rainForest.Name)); + + + foreach (var warehouse in rainForest.Warehouses) + { + System.Console.WriteLine(String.Format("This is the location of the Warehouse: {0}", warehouse.location)); + foreach (var container in warehouse.Containers) + { + System.Console.WriteLine(String.Format("The container in this Warehouse: {0}", container.name)); + foreach (var item in container.Items) + { + index.Add(item.name, container.name); + System.Console.WriteLine(String.Format("The item in the Container: {0} = ${1}", item.name, item.price)); + } + } + } + System.Console.WriteLine("Hey what do you want to look for?"); + string userinput = Console.ReadLine().ToLower(); + + + foreach (var i in index) + { + if (userinput == i.Key.ToLower()) + { + System.Console.WriteLine("Here is where they are: {0}", i.Value); + } + } + } + } + + class Company + { + public string Name { get; set; } + public List Warehouses = new List(); + public Company(string name) + { + this.Name = name; + } + + } + + class Warehouse + { + public string location { get; set; } + public int size { get; set; } + public List Containers = new List(); + public Warehouse(string location, int size) + { + this.location = location; + this.size = size; + } + } + + class Container + { + public string name { get; set; } + public int size { get; set; } + public int id { get; set; } + public List Items = new List(); + public Container(string name, int size, int id) + { + this.name = name; + this.size = size; + this.id = id; + } + } + + class Item + { + public string name { get; set; } + public double price { get; set; } + public Item(string name, double price) + { + this.name = name; + this.price = price; + } + } +} diff --git a/OOP1/Rainforest/Rainforest.csproj b/OOP1/Rainforest/Rainforest.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/OOP1/Rainforest/Rainforest.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + + diff --git a/OOP1/StarWars/Program.cs b/OOP1/StarWars/Program.cs new file mode 100644 index 00000000..745b17e0 --- /dev/null +++ b/OOP1/StarWars/Program.cs @@ -0,0 +1,145 @@ +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 solo = new Person("Han", "Solo", "Rebel"); + Person vader = new Person("Darth", "Vader", "Imperial"); + Person emperor = new Person("Emperor", "Palpatine", "Imperial"); + Ship falcon = new Ship("Rebel", "Smuggling", 2); + Ship tie = new Ship("Tie", "Fighter", 1); + Ship wing = new Ship("X-Wing", "Fighter", 3); + Station rebel = new Station("Rebel Space Station", "Rebel", 15); + Station deathStar = new Station("Death Star", "Imperial", 100); + Station cloudCity = new Station("CloudCity", "Imperial", 25); + + falcon.EnterShip(leia, 0); + falcon.EnterShip(solo, 1); + + Console.WriteLine(luke.FullName); + cloudCity.dockShip(falcon); + Console.WriteLine(cloudCity.shipRoster); + } +} + +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 +{ + public Person[] passengers; + public string name { get; set; } + public Ship(string shipName, string type, int size) + { + this.Type = type; + this.name = shipName; + this.passengers = new Person[size]; + } + + 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 shipRoster + { + get + { + foreach (var ship in ships) + { + if (ship != null) + { + Console.WriteLine(String.Format("This is a {0} ship. Here are the passengers:", ship.name)); + Console.WriteLine(ship.Passengers); + } + } + + return "Roster Complete"; + } + } + public void dockShip(Ship ship) + { + for (int i = 0; i < ships.Length; i++) + { + if (ships[i] == null) + { + ships[i] = ship; + break; + } + } + } + Ship[] ships; + public string stationName; + private string alliance; + private int size; + public Station(string stationName, string alliance, int size) + { + this.stationName = stationName; + this.alliance = alliance; + this.size = size; + this.ships = new Ship[size]; + } +} \ No newline at end of file diff --git a/OOP1/StarWars/StarWars.csproj b/OOP1/StarWars/StarWars.csproj new file mode 100644 index 00000000..21dff5ca --- /dev/null +++ b/OOP1/StarWars/StarWars.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.2 + + +