Skip to content
Open

Oop1 #10

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
28 changes: 28 additions & 0 deletions OOP1/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
,]
}
15 changes: 15 additions & 0 deletions OOP1/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CarGarage/CarGarage.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
28 changes: 28 additions & 0 deletions OOP1/CarGarage/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
,]
}
15 changes: 15 additions & 0 deletions OOP1/CarGarage/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CarGarage.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
8 changes: 8 additions & 0 deletions OOP1/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.2</TargetFramework>
</PropertyGroup>

</Project>
92 changes: 92 additions & 0 deletions OOP1/CarGarage/Program.cs
Original file line number Diff line number Diff line change
@@ -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<Person>();
}
public string Color { get; private set; }
public List<Person> 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; }
}
}
111 changes: 111 additions & 0 deletions OOP1/Rainforest/Program.cs
Original file line number Diff line number Diff line change
@@ -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<string, string> index = new Dictionary<string, string>();

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<Warehouse> Warehouses = new List<Warehouse>();
public Company(string name)
{
this.Name = name;
}

}

class Warehouse
{
public string location { get; set; }
public int size { get; set; }
public List<Container> Containers = new List<Container>();
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<Item> Items = new List<Item>();
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;
}
}
}
8 changes: 8 additions & 0 deletions OOP1/Rainforest/Rainforest.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.2</TargetFramework>
</PropertyGroup>

</Project>
Loading