diff --git a/Program.cs b/Program.cs
index 111df8d..1f80797 100644
--- a/Program.cs
+++ b/Program.cs
@@ -4,9 +4,37 @@ namespace ooad_csharp_oop
{
class Program
{
- static void Main(string[] args)
- {
- Console.WriteLine("Hello World!");
+ public static void Main(string[] args) {
+ // ឧទាហរណ៍ទី១
+ double distance, hour, fuel = 0.0;
+ Console.Write("Enter the Distance: ");
+ distance = Double.Parse(Console.ReadLine());
+ Console.Write("Enter the Hours: ");
+ hour = Double.Parse(Console.ReadLine());
+ Console.Write("Enter the Fuel: ");
+ fuel = Double.Parse(Console.ReadLine());
+
+ Car objCar = new Car(distance, hour, fuel);
+ Vehicle objVeh = objCar;
+ objCar.Average();
+ objVeh.Average();
+ objCar.Speed();
+ objVeh.Speed();
+ Console.ReadKey();
+
+ // ឧទាហរណ៍ទី២
+ double length, width, radius = 0.0;
+ Console.Write("Enter the Length: ");
+ length = Double.Parse(Console.ReadLine());
+ Console.Write("Enter the Width: ");
+ width = Double.Parse(Console.ReadLine());
+ Rectangle objRectangle = new Rectangle(length, width);
+ objRectangle.Area();
+ Console.Write("Enter the Radius: ");
+ radius = Double.Parse(Console.ReadLine());
+ Circle objCircle = new Circle(radius);
+ objCircle.Area();
+ Console.ReadKey();
}
}
}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..ebe20d2
--- /dev/null
+++ b/README.md
@@ -0,0 +1,9 @@
+"# ooad-csharp-oop"
+
+**OOP Part2** Virtual Class in C#
+
+
+
+ What is a Virtual Method in C#?
+ In object-oriented programming, a virtual method can be changed by an overriding member in a derived class by a method with the same signature. In order to create virtual method, precede the method's declaration in the base class with the "virtual" modifier.
+
\ No newline at end of file
diff --git a/Shape.cs b/Shape.cs
new file mode 100644
index 0000000..b20b5a5
--- /dev/null
+++ b/Shape.cs
@@ -0,0 +1,43 @@
+using System;
+
+namespace ooad_csharp_oop
+{
+ // ឧទាហរណ៍ទី២
+ public class Shape
+ {
+ protected double length = 0.0;
+ protected double radius = 0.0;
+ protected double width = 0.0;
+
+ public Shape(double length, double width) {
+ this.length = length;
+ this.width = width;
+ }
+
+ public Shape(double radius) {
+ this.radius = radius;
+ }
+
+ public virtual void Area() {
+ double area = 0.0;
+ area = Math.PI * Math.Pow(radius, 2);
+ Console.WriteLine("Area of Shape is :{0:0.00} ", area);
+ }
+ }
+
+ public class Rectangle : Shape {
+ public Rectangle(double length, double width)
+ : base(length, width) {
+ }
+ public override void Area() {
+ double area = 0.0;
+ area = length * width;
+ Console.WriteLine("Area of Rectangle is : {0:0.00} ", area);
+ }
+ }
+ public class Circle : Shape {
+ public Circle(double radius)
+ : base(radius) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/Vehicle.cs b/Vehicle.cs
new file mode 100644
index 0000000..bf5a77b
--- /dev/null
+++ b/Vehicle.cs
@@ -0,0 +1,46 @@
+namespace ooad_csharp_oop
+{
+ // ឧទាហរណ៍ទី១
+ public class Vehicle
+ {
+ protected double distance = 0.0;
+ protected double hour = 0.0;
+ protected double fuel = 0.0;
+
+ public Vehicle(double distance, double hour, double fuel) {
+ this.distance = distance;
+ this.hour = hour;
+ this.fuel = fuel;
+ }
+
+ public virtual void Average() {
+ double average = 0.0;
+ average = distance / fuel;
+ System.Console.WriteLine("Vehicle Average is {0:0.00}", average);
+ }
+
+ public virtual void Speed() {
+ double speed = 0.0;
+ speed = distance / hour;
+ System.Console.WriteLine("Vehicle Average is {0:0.00}", speed);
+ }
+ }
+
+ public class Car : Vehicle {
+ public Car(double distance, double hour, double fuel)
+ : base(distance, hour, fuel) {
+ }
+
+ public override void Average() {
+ double average = 0.0;
+ average = distance / fuel;
+ System.Console.WriteLine("Vehicle Average is {0:0.00}", average);
+ }
+
+ public override void Speed() {
+ double speed = 0.0;
+ speed = distance / hour;
+ System.Console.WriteLine("Vehicle Average is {0:0.00}", speed);
+ }
+ }
+}
\ No newline at end of file
diff --git a/bin/Debug/net5.0/ooad-csharp-oop.deps.json b/bin/Debug/net5.0/ooad-csharp-oop.deps.json
new file mode 100644
index 0000000..c1d3229
--- /dev/null
+++ b/bin/Debug/net5.0/ooad-csharp-oop.deps.json
@@ -0,0 +1,23 @@
+{
+ "runtimeTarget": {
+ "name": ".NETCoreApp,Version=v5.0",
+ "signature": ""
+ },
+ "compilationOptions": {},
+ "targets": {
+ ".NETCoreApp,Version=v5.0": {
+ "ooad-csharp-oop/1.0.0": {
+ "runtime": {
+ "ooad-csharp-oop.dll": {}
+ }
+ }
+ }
+ },
+ "libraries": {
+ "ooad-csharp-oop/1.0.0": {
+ "type": "project",
+ "serviceable": false,
+ "sha512": ""
+ }
+ }
+}
\ No newline at end of file
diff --git a/bin/Debug/net5.0/ooad-csharp-oop.dll b/bin/Debug/net5.0/ooad-csharp-oop.dll
new file mode 100644
index 0000000..09bbc0b
Binary files /dev/null and b/bin/Debug/net5.0/ooad-csharp-oop.dll differ
diff --git a/bin/Debug/net5.0/ooad-csharp-oop.exe b/bin/Debug/net5.0/ooad-csharp-oop.exe
new file mode 100644
index 0000000..d694905
Binary files /dev/null and b/bin/Debug/net5.0/ooad-csharp-oop.exe differ
diff --git a/bin/Debug/net5.0/ooad-csharp-oop.pdb b/bin/Debug/net5.0/ooad-csharp-oop.pdb
new file mode 100644
index 0000000..ce25e31
Binary files /dev/null and b/bin/Debug/net5.0/ooad-csharp-oop.pdb differ
diff --git a/bin/Debug/net5.0/ooad-csharp-oop.runtimeconfig.dev.json b/bin/Debug/net5.0/ooad-csharp-oop.runtimeconfig.dev.json
new file mode 100644
index 0000000..6c8a7b3
--- /dev/null
+++ b/bin/Debug/net5.0/ooad-csharp-oop.runtimeconfig.dev.json
@@ -0,0 +1,8 @@
+{
+ "runtimeOptions": {
+ "additionalProbingPaths": [
+ "C:\\Users\\DELL\\.dotnet\\store\\|arch|\\|tfm|",
+ "C:\\Users\\DELL\\.nuget\\packages"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/bin/Debug/net5.0/ooad-csharp-oop.runtimeconfig.json b/bin/Debug/net5.0/ooad-csharp-oop.runtimeconfig.json
new file mode 100644
index 0000000..a8e7e82
--- /dev/null
+++ b/bin/Debug/net5.0/ooad-csharp-oop.runtimeconfig.json
@@ -0,0 +1,9 @@
+{
+ "runtimeOptions": {
+ "tfm": "net5.0",
+ "framework": {
+ "name": "Microsoft.NETCore.App",
+ "version": "5.0.0"
+ }
+ }
+}
\ No newline at end of file
diff --git a/bin/Debug/net5.0/ref/ooad-csharp-oop.dll b/bin/Debug/net5.0/ref/ooad-csharp-oop.dll
new file mode 100644
index 0000000..6af1486
Binary files /dev/null and b/bin/Debug/net5.0/ref/ooad-csharp-oop.dll differ
diff --git a/obj/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs b/obj/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs
new file mode 100644
index 0000000..2f7e5ec
--- /dev/null
+++ b/obj/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs
@@ -0,0 +1,4 @@
+//
+using System;
+using System.Reflection;
+[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]
diff --git a/obj/Debug/net5.0/apphost.exe b/obj/Debug/net5.0/apphost.exe
new file mode 100644
index 0000000..d694905
Binary files /dev/null and b/obj/Debug/net5.0/apphost.exe differ
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.AssemblyInfo.cs b/obj/Debug/net5.0/ooad-csharp-oop.AssemblyInfo.cs
new file mode 100644
index 0000000..f8a1f0f
--- /dev/null
+++ b/obj/Debug/net5.0/ooad-csharp-oop.AssemblyInfo.cs
@@ -0,0 +1,22 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+using System;
+using System.Reflection;
+
+[assembly: System.Reflection.AssemblyCompanyAttribute("ooad-csharp-oop")]
+[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
+[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
+[assembly: System.Reflection.AssemblyProductAttribute("ooad-csharp-oop")]
+[assembly: System.Reflection.AssemblyTitleAttribute("ooad-csharp-oop")]
+[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
+
+// Generated by the MSBuild WriteCodeFragment class.
+
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.AssemblyInfoInputs.cache b/obj/Debug/net5.0/ooad-csharp-oop.AssemblyInfoInputs.cache
new file mode 100644
index 0000000..a1c751e
--- /dev/null
+++ b/obj/Debug/net5.0/ooad-csharp-oop.AssemblyInfoInputs.cache
@@ -0,0 +1 @@
+7b6ab281c8c6ab7e1e3827a9a4f484ff73b5835f
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net5.0/ooad-csharp-oop.GeneratedMSBuildEditorConfig.editorconfig
new file mode 100644
index 0000000..280e2ff
--- /dev/null
+++ b/obj/Debug/net5.0/ooad-csharp-oop.GeneratedMSBuildEditorConfig.editorconfig
@@ -0,0 +1,10 @@
+is_global = true
+build_property.TargetFramework = net5.0
+build_property.TargetPlatformMinVersion =
+build_property.UsingMicrosoftNETSdkWeb =
+build_property.ProjectTypeGuids =
+build_property.PublishSingleFile =
+build_property.IncludeAllContentForSelfExtract =
+build_property._SupportedPlatformList = Android,iOS,Linux,macOS,Windows
+build_property.RootNamespace = ooad_csharp_oop
+build_property.ProjectDir = D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.assets.cache b/obj/Debug/net5.0/ooad-csharp-oop.assets.cache
new file mode 100644
index 0000000..483d3c0
Binary files /dev/null and b/obj/Debug/net5.0/ooad-csharp-oop.assets.cache differ
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.csproj.AssemblyReference.cache b/obj/Debug/net5.0/ooad-csharp-oop.csproj.AssemblyReference.cache
new file mode 100644
index 0000000..e75313f
Binary files /dev/null and b/obj/Debug/net5.0/ooad-csharp-oop.csproj.AssemblyReference.cache differ
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.csproj.CoreCompileInputs.cache b/obj/Debug/net5.0/ooad-csharp-oop.csproj.CoreCompileInputs.cache
new file mode 100644
index 0000000..cbb1dbe
--- /dev/null
+++ b/obj/Debug/net5.0/ooad-csharp-oop.csproj.CoreCompileInputs.cache
@@ -0,0 +1 @@
+509c4ee89f47d0d75b991614751ade6eb08e7501
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.csproj.FileListAbsolute.txt b/obj/Debug/net5.0/ooad-csharp-oop.csproj.FileListAbsolute.txt
new file mode 100644
index 0000000..b2a4feb
--- /dev/null
+++ b/obj/Debug/net5.0/ooad-csharp-oop.csproj.FileListAbsolute.txt
@@ -0,0 +1,16 @@
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\bin\Debug\net5.0\ooad-csharp-oop.exe
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\bin\Debug\net5.0\ooad-csharp-oop.deps.json
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\bin\Debug\net5.0\ooad-csharp-oop.runtimeconfig.json
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\bin\Debug\net5.0\ooad-csharp-oop.runtimeconfig.dev.json
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\bin\Debug\net5.0\ooad-csharp-oop.dll
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\bin\Debug\net5.0\ref\ooad-csharp-oop.dll
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\bin\Debug\net5.0\ooad-csharp-oop.pdb
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\obj\Debug\net5.0\ooad-csharp-oop.csproj.AssemblyReference.cache
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\obj\Debug\net5.0\ooad-csharp-oop.GeneratedMSBuildEditorConfig.editorconfig
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\obj\Debug\net5.0\ooad-csharp-oop.AssemblyInfoInputs.cache
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\obj\Debug\net5.0\ooad-csharp-oop.AssemblyInfo.cs
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\obj\Debug\net5.0\ooad-csharp-oop.csproj.CoreCompileInputs.cache
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\obj\Debug\net5.0\ooad-csharp-oop.dll
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\obj\Debug\net5.0\ref\ooad-csharp-oop.dll
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\obj\Debug\net5.0\ooad-csharp-oop.pdb
+D:\RUPP-Year4\OOAD\Object Oriented Programming\ooad-csharp-oop\obj\Debug\net5.0\ooad-csharp-oop.genruntimeconfig.cache
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.dll b/obj/Debug/net5.0/ooad-csharp-oop.dll
new file mode 100644
index 0000000..09bbc0b
Binary files /dev/null and b/obj/Debug/net5.0/ooad-csharp-oop.dll differ
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.genruntimeconfig.cache b/obj/Debug/net5.0/ooad-csharp-oop.genruntimeconfig.cache
new file mode 100644
index 0000000..8a5590d
--- /dev/null
+++ b/obj/Debug/net5.0/ooad-csharp-oop.genruntimeconfig.cache
@@ -0,0 +1 @@
+34449263d8659535b6222a9aa6e0c4f246eee350
diff --git a/obj/Debug/net5.0/ooad-csharp-oop.pdb b/obj/Debug/net5.0/ooad-csharp-oop.pdb
new file mode 100644
index 0000000..ce25e31
Binary files /dev/null and b/obj/Debug/net5.0/ooad-csharp-oop.pdb differ
diff --git a/obj/Debug/net5.0/ref/ooad-csharp-oop.dll b/obj/Debug/net5.0/ref/ooad-csharp-oop.dll
new file mode 100644
index 0000000..6af1486
Binary files /dev/null and b/obj/Debug/net5.0/ref/ooad-csharp-oop.dll differ