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 CarLot/CarLot.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>
100 changes: 100 additions & 0 deletions CarLot/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;

namespace OOP3
{

public class Program {

public static void Main(String[] args)
{
CarLot CL1 = new CarLot("Chase's Cars");
CarLot CL2 = new CarLot("Other guys' Cars");
Car mazda = new Car("White", "Mazda", "3", "Hatchback");
Car subaru = new Car("Black", "Subaru", "Impreza", "Sedan");
Car chevy = new Car("Silver", "Chevy", "Malibu", "Sedan");
Car toyota = new Car("Green", "Toyota", "Celica", "Coupe");
Truck f150 = new Truck("Red", "Ford", "F-150", 5);
Truck titan = new Truck("Gray","Nissan","Titan", 5);
Truck ram = new Truck("Black", "Dodge", "Ram", 6);
CL1.Add(mazda);
CL1.Add(subaru);
CL1.Add(f150);
CL2.Add(toyota);
CL2.Add(titan);
CL2.Add(ram);

CL1.PrintInventory();
CL2.PrintInventory();

}

}

public class CarLot {
List<Vehicle> inventory;
String name;

public CarLot(string intialName){
this.name = intialName;
}

public void Add(Vehicle vehicle){
inventory.Add(vehicle);
}

public void PrintInventory(){
foreach(var vehicle in inventory){
Console.WriteLine(vehicle.ToString());
}
}
}

public abstract class Vehicle {

string color;
string make;
string model;

public Vehicle(string intialColor, string intialMake, string intialModel){
this.color = intialColor;
this.make = intialMake;
this.model = intialModel;
}

override
public String ToString(){
String s1 = string.Format(this.color + "" + this.make + "" + this.model + "");
return s1;
}

}

public class Car : Vehicle{

string bodyType;

public Car(string initialColor, string initialMake, string intialModel, string intialBodyType) :
base(initialColor, initialMake, intialModel ){
this.bodyType = intialBodyType;

}

override
public String ToString(){
String s2 = string.Format(this.bodyType);
return s2;
}

}

public class Truck : Vehicle {

int cabSize;

public Truck(string intialColor, string initialMake, string intialModel, int initialCabSize) :
base(intialColor, initialMake, intialModel){
this.cabSize = initialCabSize;
}
}
}
8 changes: 8 additions & 0 deletions OOP2/OOP2.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>
67 changes: 67 additions & 0 deletions OOP2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;

namespace OOP2
{
class Program
{
static void Main(string[] args)
{
_2DPoint p1 = new _2DPoint(3,4);
_3DPoint p2 = new _3DPoint(6,2,8);
_2DPoint p3 = new _2DPoint(3,4);

Console.WriteLine("p1 = {0}", p1);
Console.WriteLine("p2 = {0}", p2);



}
}


public class _2DPoint
{
public int x;
public int y;

public _2DPoint(int initialX, int initialY){
this.x = initialX;
this.y = initialY;

}
override
public String ToString(){
String s = String.Format("{0} , {1}", x, y);
return s;
}
override
public bool Equals(Object otherObject){
_2DPoint otherpoint = (_2DPoint) otherObject;
if(this.x == otherpoint.x && this.y == otherpoint.y ){
return true;
}
else{
return false;
}
}
}
public class _3DPoint : _2DPoint
{
public int z;
public _3DPoint(int initialX, int initialY, int initialZ) :
base ( initialX, initialY){
this.x = initialX;
this.y = initialY;
this.z = initialZ;
}
override
public String ToString()
{
String s = String.Format("{0}, {1}, {2},", x, y, z);
return s;
}
}

}