From 1213eaab22c01a952f4a9fc806dfddbffed2c2ac Mon Sep 17 00:00:00 2001 From: Sam Mangum-Bostick Date: Sun, 3 Feb 2019 15:08:55 -0600 Subject: [PATCH 1/3] Started outline --- OOP1/CarGarage/.vscode/launch.json | 28 ++++++++++++ OOP1/CarGarage/.vscode/tasks.json | 15 +++++++ OOP1/CarGarage/CarGarage.csproj | 8 ++++ OOP1/CarGarage/Program.cs | 71 ++++++++++++++++++++++++++++++ OOP1/Rainforest/Program.cs | 12 +++++ OOP1/Rainforest/Rainforest.csproj | 8 ++++ OOP1/StarWars/Program.cs | 12 +++++ OOP1/StarWars/StarWars.csproj | 8 ++++ 8 files changed, 162 insertions(+) create mode 100644 OOP1/CarGarage/.vscode/launch.json create mode 100644 OOP1/CarGarage/.vscode/tasks.json create mode 100644 OOP1/CarGarage/CarGarage.csproj create mode 100644 OOP1/CarGarage/Program.cs create mode 100644 OOP1/Rainforest/Program.cs create mode 100644 OOP1/Rainforest/Rainforest.csproj create mode 100644 OOP1/StarWars/Program.cs create mode 100644 OOP1/StarWars/StarWars.csproj 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..a14fa6f2 --- /dev/null +++ b/OOP1/CarGarage/Program.cs @@ -0,0 +1,71 @@ +using System; + +namespace CarGarage +{ + class Program + { + static void Main(string[] args) + { + Car blueCar = new Car(); + Garage smallGarage = new Garage(2); + Person person1 = new Person("Sam Bostick"); + + smallGarage.ParkCar(blueCar, 0); + Console.WriteLine(smallGarage.Cars); + } + } + class Car + { + public Car(string initialColor) + { + Color = initialColor; + } + public string Color { get; private set; } + public Car() + { + + } + + } + + 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 class Person + { + public Person(string person1) + { + Name = person1; + } + + public string Name { get; private set; } + } +} diff --git a/OOP1/Rainforest/Program.cs b/OOP1/Rainforest/Program.cs new file mode 100644 index 00000000..cf853def --- /dev/null +++ b/OOP1/Rainforest/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace Rainforest +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} 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..1974d609 --- /dev/null +++ b/OOP1/StarWars/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace StarWars +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} 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 + + + From f035e053e05e3608a468410dee37aafa216707f5 Mon Sep 17 00:00:00 2001 From: Sam Mangum-Bostick Date: Wed, 6 Feb 2019 18:25:00 -0600 Subject: [PATCH 2/3] Finished Garage --- OOP1/.vscode/launch.json | 28 +++++++++++++ OOP1/.vscode/tasks.json | 15 +++++++ OOP1/CarGarage/Program.cs | 55 ++++++++++++++++++-------- OOP1/StarWars/Program.cs | 83 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 160 insertions(+), 21 deletions(-) create mode 100644 OOP1/.vscode/launch.json create mode 100644 OOP1/.vscode/tasks.json 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/Program.cs b/OOP1/CarGarage/Program.cs index a14fa6f2..947e944b 100644 --- a/OOP1/CarGarage/Program.cs +++ b/OOP1/CarGarage/Program.cs @@ -1,34 +1,54 @@ using System; +using System.Collections.Generic; -namespace CarGarage +namespace OOP1 { - class Program + public class Program { - static void Main(string[] args) + public static void Main() { - Car blueCar = new Car(); Garage smallGarage = new Garage(2); - Person person1 = new Person("Sam Bostick"); - + 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); } } - class Car + + public class Car { public Car(string initialColor) { Color = initialColor; + this.passengers = new List(); } public string Color { get; private set; } - public Car() + 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; + } + } } - - class Garage + public class Garage { private Car[] cars; @@ -37,13 +57,13 @@ 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 @@ -52,20 +72,21 @@ public string Cars { if (cars[i] != null) { - Console.WriteLine(String.Format("The {0} car is in spot {1}.", cars[i].Color, i)); + 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 person1) + public Person(string initialName) { - Name = person1; + Name = initialName; } - public string Name { get; private set; } } -} +} \ No newline at end of file diff --git a/OOP1/StarWars/Program.cs b/OOP1/StarWars/Program.cs index 1974d609..ba60651b 100644 --- a/OOP1/StarWars/Program.cs +++ b/OOP1/StarWars/Program.cs @@ -1,12 +1,87 @@ using System; -namespace StarWars +public class Program { - class Program + public static void Main() { - static void Main(string[] args) + Person leia = new Person("Leia", "Organa", "Rebel"); + Person darth = new Person("Darth", "Vader", "Imperial"); + Ship falcon = new Ship("Rebel", "Smuggling", 2); + Ship tie = new Ship("Tie", "Fighter", 1); + Console.WriteLine("Hello world!"); + } +} + +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 { - Console.WriteLine("Hello World!"); + 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 alliance, string type, int size) + { + this.Type = type; + this.Alliance = alliance; + 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; + } +} \ No newline at end of file From 2f08c38c03e83604f19134fb58a08530f8416c8e Mon Sep 17 00:00:00 2001 From: Sam Mangum-Bostick Date: Mon, 11 Feb 2019 19:29:40 -0600 Subject: [PATCH 3/3] Completed all Projects --- OOP1/Rainforest/Program.cs | 101 ++++++++++++++++++++++++++++++++++++- OOP1/StarWars/Program.cs | 68 +++++++++++++++++++++++-- 2 files changed, 163 insertions(+), 6 deletions(-) diff --git a/OOP1/Rainforest/Program.cs b/OOP1/Rainforest/Program.cs index cf853def..e0ef01f8 100644 --- a/OOP1/Rainforest/Program.cs +++ b/OOP1/Rainforest/Program.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; + namespace Rainforest { @@ -6,7 +8,104 @@ class Program { static void Main(string[] args) { - Console.WriteLine("Hello World!"); + 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/StarWars/Program.cs b/OOP1/StarWars/Program.cs index ba60651b..745b17e0 100644 --- a/OOP1/StarWars/Program.cs +++ b/OOP1/StarWars/Program.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; + public class Program { @@ -6,9 +8,23 @@ 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); - Console.WriteLine("Hello world!"); + 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); } } @@ -42,11 +58,12 @@ public string FullName class Ship { - private Person[] passengers; - public Ship(string alliance, string type, int size) + public Person[] passengers; + public string name { get; set; } + public Ship(string shipName, string type, int size) { this.Type = type; - this.Alliance = alliance; + this.name = shipName; this.passengers = new Person[size]; } @@ -70,7 +87,6 @@ public string Passengers { Console.WriteLine(String.Format("{0}", person.FullName)); } - return "That's Everybody!"; } } @@ -84,4 +100,46 @@ 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