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

namespace Cars
{

public class Program
{
public static void Main(String[] args)
{
// Instantiates instances of CarLot, each is an empty List (instance name: inventory) based on Class Vehicle
CarLot edsSouth = new CarLot("South Lot");
CarLot edsNorth = new CarLot("North Lot");

// Instantiates instances of Car (using base Class Vehicle). Passes the parameters cooresponding to the Class parameters
Car Escort = new Car("Ford", "Escort", "Tx-123", 8000, "Hatchback", 4);
Car Mustang = new Car("Ford", "Mustang", "Tx-654", 15000, "Coupe", 4);

// Instantiates instances of Truck (using base Class Vehicle). Passes the parameters cooresponding to the Class parameters
Truck SuperDuty = new Truck("Ford", "SuperDuty", "Tx-987", 20000, "LongBed");
Truck Ram = new Truck("Dodge", "Ram", "Tx-456", 10000, "LongBed");

// Method Call chained to CarLot Class list variable - passes through a Class Vehicle parameter
// Calls Class Object (which is either a Car:Vehicle or Truck:Vehicle) and ads it to the CarLot list
// The "return" of either Class is the object added to the CarLot list
edsSouth.addCar(Escort);
edsSouth.addCar(Ram);

edsNorth.addCar(Mustang);
edsNorth.addCar(SuperDuty);

// Method Call chained to CarLot Class list variable - method is void, no parameter
edsSouth.PrintInventory();
edsNorth.PrintInventory();

Console.ReadLine();
}
}

public class CarLot
{
// Field defines a List called inventory (variable) with a (Class: Vehicle) value
List<Vehicle> inventory;
String name;

// Paremeterized Constructor - when called it creates a blank instance of a List
// It takes in a string passed in from the instance call (ex: "South Lot")
public CarLot(string Lname)
{
//Constructor - when called it creates an empty instance of CarLot List called "this.inventory"
this.inventory = new List<Vehicle>();
//Constructor parameter - takes parameter and sets it to this.name instance variable (ex: "South Lot")
this.name = Lname;
}

// Method addCar - takes in a Class: Vehicle type and sets it to the object variable "vehicle"
public void addCar(Vehicle vehicle)
{
// Method - when called it adds a vehicle according to the vehicle class and parameters passed in
this.inventory.Add(vehicle);
}

// Method PrintInventory - Void - takes in no parameters
public void PrintInventory()
{
// Prints the current instance Car Lot "this.name" and the count of objects in the list (cars)
Console.WriteLine("Eds Cars Lot: {0} Car Count: {1}", this.name, this.inventory.Count);

// loops through each object in the current instance of CarLot list and prints the contents, each vehicle
for(int i = 0; i < this.inventory.Count; i++)
{
Console.WriteLine("Vehicle Inventory: {0}", this.inventory[i]);
}
Console.WriteLine();
}
}

public abstract class Vehicle
{
public string make;
public string model;
public string license;
public int price;
public Vehicle(string Tmake, string Tmodel, string Tlicense, int Tprice)
{
make = Tmake;
model = Tmodel;
license = Tlicense;
price = Tprice;
}

}

// Class Car : Vehicle - takes in parameters accorting to its Constructor - instance generator must match
// Car : Vehicle - returns the string value in the ToString (override) Method
public class Car : Vehicle
{
public string Ctype;
public int Cdoors;
public Car(string Tmake, string Tmodel, string Tlicense, int Tprice, string type, int doors) : base (Tmake, Tmodel, Tlicense, Tprice)
{
Ctype = type;
Cdoors = doors;
}

override public String ToString()
{
String s = "";
s = (" Car Make: " +make +" Model: " +model +" License: " +license +" Type: " +Ctype +" Doors: " +Cdoors +" Price: " +price);
return s;
}
}

// Class Truck : Vehicle - takes in parameters accorting to its Constructor - instance generator must match
// Truck : Vehicle - returns the string value in the ToString (override) Method
public class Truck : Vehicle
{
public string Tbed;

public Truck(string Tmake, string Tmodel, string Tlicense, int Tprice, string bed) : base (Tmake, Tmodel, Tlicense, Tprice)
{
Tbed = bed;
}

override public String ToString()
{
String s = "";
s = (" Truck Make: " +make +" Model: " +model +" Bed Size: " +Tbed +" License: " +license +" Price: " +price);
return s;
}
}
}
22 changes: 21 additions & 1 deletion Files/Files.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
using System;
using System.IO;

namespace Files
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
string[] lines = System.IO.File.ReadAllLines("/Users/afogarasi/Desktop/words_alpha.txt");

System.IO.File.WriteAllLines("/Users/afogarasi/Desktop/words.2_alpha.txt", lines);

StreamReader stream = File.OpenText("/Users/afogarasi/Desktop/words_alpha.txt");

FileStream outStream = File.OpenWrite("/Users/afogarasi/Desktop/words3_alpha.txt");

StreamWriter s = new StreamWriter (outStream);


string line = stream.ReadLine();
while (line != null)
{
Console.WriteLine(line);
line = stream.ReadLine();
}

s.Close();
stream.Close();
}
}
}
8 changes: 8 additions & 0 deletions OOPDay1/OOPDay1.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>
102 changes: 102 additions & 0 deletions OOPDay1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;


namespace OOPDay1
{
class Program
{
static void Main(string[] args)
{
Person Passenger = new Person("Tom");
Car NextCar = new Car("Blue", 4);
Garage smallGarage = new Garage(2);

NextCar.SeatPerson(Passenger, 0);
Console.WriteLine(NextCar.People);

smallGarage.ParkCar(NextCar, 0);
Console.WriteLine(smallGarage.Cars);
}
}

public class Person
{
// Constructor creates an instance of a Person
public Person(string initialGender)
{
gender = initialGender;
}

public string gender { get; private set; }
}

class Car
{
private Person[] persons;

// Constructor creates an instance of a Car with attributes of Size (seats) and Color
public Car(String initialColor, int initialSize)
{
Color = initialColor;
Size = initialSize;
this.persons = new Person[initialSize];
}

public String Color;
public int Size { get; private set; }


// Method to get an instance of a person and place that person in a seat (index) of the "persons" array
public void SeatPerson (Person person, int seat)
{
persons[seat] = person;
}

// Method prints out where each instance of People is sitting in a car (seat) and the color of the car
public string People {
get {
for (int i = 0; i < persons.Length; i++)
{
if (persons[i] != null) {
Console.WriteLine(String.Format("Passenger {0} is in seat {1} of the {2} car", persons[i].gender, i+1, Color));
}
}
return "Where is it parked?";
}
}
}
class Garage
{
private Car[] cars;

// Constructor creates an instance a garage with attributes of number of parking spaces (Space)
public Garage(int initialSpace)
{
Space = initialSpace;
this.cars = new Car[initialSpace];
}

public int Space { get; private set; }

// Method to get an instance of a Car and place that car in a parking spot (index) of the "cars" array
public void ParkCar (Car car, int spot)
{
cars[spot] = car;
}

// Method prints out where each instance of Car is parked in a Garage (spot) in the Small Garage
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} of the Small Garage.", cars[i].Color, i+1));
}
}
return "That's all!";
}
}
}
}
8 changes: 8 additions & 0 deletions OOPGarage/OOPGarage.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