Skip to content

Commit

Permalink
Add Day 2 programs
Browse files Browse the repository at this point in the history
  • Loading branch information
cvpfus committed Sep 5, 2023
1 parent 42e0e46 commit b83ba8d
Show file tree
Hide file tree
Showing 26 changed files with 395 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Bootcamp batch 5.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Day1", "Day1", "{44C682DF-E
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project2", "Project2\Project2.csproj", "{AA5CB577-831E-40F5-AABD-AFF7C56F8A57}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Constructor", "Constructor\Constructor.csproj", "{1A0A5FD8-8FC2-4ECA-8EB0-BAC6DF70E7BF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Day2", "Day2", "{0458C07F-2B31-4DB7-97E4-315800A0B2C0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassObject", "ClassObject\ClassObject.csproj", "{CAFB081F-E8AC-4A0F-A9EA-EE641A5254A8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Inheritance", "Inheritance\Inheritance.csproj", "{F934B55C-79B7-4C89-929E-1651D392E609}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interface", "Interface\Interface.csproj", "{9CAF1E8C-A9B8-45AF-A457-C8A5010A5772}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Encapsulation", "Encapsulation\Encapsulation.csproj", "{36234DA2-59A9-48C9-B564-EC6C19620F03}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -26,8 +38,33 @@ Global
{AA5CB577-831E-40F5-AABD-AFF7C56F8A57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA5CB577-831E-40F5-AABD-AFF7C56F8A57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA5CB577-831E-40F5-AABD-AFF7C56F8A57}.Release|Any CPU.Build.0 = Release|Any CPU
{1A0A5FD8-8FC2-4ECA-8EB0-BAC6DF70E7BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A0A5FD8-8FC2-4ECA-8EB0-BAC6DF70E7BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A0A5FD8-8FC2-4ECA-8EB0-BAC6DF70E7BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A0A5FD8-8FC2-4ECA-8EB0-BAC6DF70E7BF}.Release|Any CPU.Build.0 = Release|Any CPU
{CAFB081F-E8AC-4A0F-A9EA-EE641A5254A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CAFB081F-E8AC-4A0F-A9EA-EE641A5254A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CAFB081F-E8AC-4A0F-A9EA-EE641A5254A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CAFB081F-E8AC-4A0F-A9EA-EE641A5254A8}.Release|Any CPU.Build.0 = Release|Any CPU
{F934B55C-79B7-4C89-929E-1651D392E609}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F934B55C-79B7-4C89-929E-1651D392E609}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F934B55C-79B7-4C89-929E-1651D392E609}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F934B55C-79B7-4C89-929E-1651D392E609}.Release|Any CPU.Build.0 = Release|Any CPU
{9CAF1E8C-A9B8-45AF-A457-C8A5010A5772}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9CAF1E8C-A9B8-45AF-A457-C8A5010A5772}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CAF1E8C-A9B8-45AF-A457-C8A5010A5772}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CAF1E8C-A9B8-45AF-A457-C8A5010A5772}.Release|Any CPU.Build.0 = Release|Any CPU
{36234DA2-59A9-48C9-B564-EC6C19620F03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36234DA2-59A9-48C9-B564-EC6C19620F03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36234DA2-59A9-48C9-B564-EC6C19620F03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36234DA2-59A9-48C9-B564-EC6C19620F03}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{36234DA2-59A9-48C9-B564-EC6C19620F03} = {0458C07F-2B31-4DB7-97E4-315800A0B2C0}
{9CAF1E8C-A9B8-45AF-A457-C8A5010A5772} = {0458C07F-2B31-4DB7-97E4-315800A0B2C0}
{F934B55C-79B7-4C89-929E-1651D392E609} = {0458C07F-2B31-4DB7-97E4-315800A0B2C0}
{CAFB081F-E8AC-4A0F-A9EA-EE641A5254A8} = {0458C07F-2B31-4DB7-97E4-315800A0B2C0}
{1A0A5FD8-8FC2-4ECA-8EB0-BAC6DF70E7BF} = {0458C07F-2B31-4DB7-97E4-315800A0B2C0}
{AA5CB577-831E-40F5-AABD-AFF7C56F8A57} = {44C682DF-E1C9-4394-813D-0CB989CD9262}
{77D0C1C7-A06B-4E05-9458-873709BD4BFD} = {44C682DF-E1C9-4394-813D-0CB989CD9262}
EndGlobalSection
Expand Down
33 changes: 33 additions & 0 deletions ClassObject/Car.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Mobil;

public class Car
{
public Engine engine;
public string? brand;
public string? tire;
public int topSpeed;

public Car(Engine engine, string brand, string tire)
{
this.engine = engine;
this.brand = brand;
this.tire = tire;
}

public Car(Engine engine, string tire, int topSpeed)
{
this.engine = engine;
this.tire = tire;
this.topSpeed = topSpeed;
}

public Engine EngineCheck()
{
return engine;
}

public int TopSpeedCheck()
{
return topSpeed;
}
}
8 changes: 8 additions & 0 deletions ClassObject/ClassObject.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>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions ClassObject/Engine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Mobil;

public class Engine
{
public string? engineType;
public int horsePower;
public int torque;
public Engine(string engineType, int horsePower, int torque)
{
this.engineType = engineType;
this.horsePower = horsePower;
this.torque = torque;
}
}
15 changes: 15 additions & 0 deletions ClassObject/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Mobil;
class Program
{
static void Main()
{
Engine engine = new Engine("v8", 495, 470);

Car honda = new Car(engine, "bridgestone", 300);

Console.WriteLine(honda.EngineCheck().engineType);
Console.WriteLine(honda.EngineCheck().horsePower);
Console.WriteLine(honda.EngineCheck().torque);
Console.WriteLine(honda.TopSpeedCheck());
}
}
33 changes: 33 additions & 0 deletions Constructor/Car.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace Constructor;

public class Car
{
public string? engine;
public string? brand;
public string? tire;
public int topSpeed;

public Car(string engine, string brand, string tire)
{
this.engine = engine;
this.brand = brand;
this.tire = tire;
}

public Car(string engine, string tire, int topSpeed)
{
this.engine = engine;
this.tire = tire;
this.topSpeed = topSpeed;
}

public string? EngineCheck()
{
return engine;
}

public int TopSpeedCheck()
{
return topSpeed;
}
}
8 changes: 8 additions & 0 deletions Constructor/Constructor.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>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
15 changes: 15 additions & 0 deletions Constructor/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Constructor;

class Program
{
static void Main()
{
Car mobil1 = new Car("v8", "honda", "bridgestone");
Console.WriteLine(mobil1.EngineCheck());

Car mobil2 = new Car("v8", "michelin", 300);
Console.WriteLine(mobil2.TopSpeedCheck());


}
}
23 changes: 23 additions & 0 deletions Encapsulation/Animal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Hewan;

public class Animal
{
protected string? _name;
protected int _age;

public Animal(string name, int age)
{
_name = name;
_age = age;
}

public string? GetName()
{
return _name;
}

public int GetAge()
{
return _age;
}
}
9 changes: 9 additions & 0 deletions Encapsulation/Cat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Hewan;

public class Cat : Animal
{
public Cat(string name, int age) : base(name, age)
{
Console.WriteLine($"Cat with name {name} and age {age} years old has been created.");
}
}
8 changes: 8 additions & 0 deletions Encapsulation/Encapsulation.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>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
10 changes: 10 additions & 0 deletions Encapsulation/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Hewan;
class Program
{
static void Main()
{
Cat kucing = new Cat("Cibi", 12);
Console.WriteLine(kucing.GetName());
Console.WriteLine(kucing.GetAge());
}
}
22 changes: 22 additions & 0 deletions Inheritance/Animal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Hewan;

public class Animal
{
public string? name;
public int age;

public Animal(string name, int age)
{
Console.WriteLine($"Animal with name {name} and age {age} years old has been created.");
}

public Animal()
{
// default constructor
}

public void Eat()
{
Console.WriteLine($"{name} has eaten.");
}
}
16 changes: 16 additions & 0 deletions Inheritance/Bird.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Hewan;

public class Bird : Animal
{
public Bird(string name, int age) : base(name, age)
{
this.name = name;
this.age = age;
Console.WriteLine($"Bird with name {name} and age {age} has been created.");
}

public void Fly()
{
Console.WriteLine($"{name} is flying happily.");
}
}
16 changes: 16 additions & 0 deletions Inheritance/Cat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Hewan;

public class Cat : Animal
{
public Cat(string name, int age) : base(name, age)
{
this.name = name;
this.age = age;
Console.WriteLine($"Cat with name {name} and age {age} has been created.");
}

public void Meow()
{
Console.WriteLine($"{name} is meowing calmly.");
}
}
15 changes: 15 additions & 0 deletions Inheritance/Dog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Hewan;

public class Dog : Animal
{
public Dog(string name, int age) : base(name, age)
{
this.name = name;
this.age = age;
Console.WriteLine($"Dog with name {name} and age {age} has been created.");
}

public void Bark() {
Console.WriteLine($"{name} is barking very loud.");
}
}
16 changes: 16 additions & 0 deletions Inheritance/Fish.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Hewan;

public class Fish : Animal
{
public Fish(string name, int age) : base(name, age)
{
this.name = name;
this.age = age;
Console.WriteLine($"Fish with name {name} and age {age} has been created.");
}

public void Swim()
{
Console.WriteLine($"{name} is swimming happily.");
}
}
8 changes: 8 additions & 0 deletions Inheritance/Inheritance.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>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions Inheritance/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Hewan;
class Program
{
static void Main()
{
Cat cat = new Cat("Cibi", 1);
cat.Meow();
cat.Eat();

Dog dog = new Dog("Gukguk", 2);
dog.Bark();
dog.Eat();
}
}
15 changes: 15 additions & 0 deletions Interface/Car.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Mobil;

public class Car
{
public IEngine? engine;
public Car(IEngine engine)
{
this.engine = engine;
}

public void RunEngine()
{
engine?.RunEngine();
}
}
9 changes: 9 additions & 0 deletions Interface/DieselEngine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Mobil;

public class DieselEngine : IEngine
{
public void RunEngine()
{
Console.WriteLine("Diesel Engine is running.");
}
}
9 changes: 9 additions & 0 deletions Interface/ElectricEngine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Mobil;

public class ElectricEngine : IEngine
{
public void RunEngine()
{
Console.WriteLine("Electric Engine is running.");
}
}
Loading

0 comments on commit b83ba8d

Please sign in to comment.