Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hands on OOP submission by Bastian Hendramukti Suryapratama #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
26 changes: 26 additions & 0 deletions Bastian Hendramukti Suryapratama_ITB/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// 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
"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/net7.0/shape.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions Bastian Hendramukti Suryapratama_ITB/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/shape.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/shape.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/shape.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
99 changes: 99 additions & 0 deletions Bastian Hendramukti Suryapratama_ITB/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
namespace shape;

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Masukkan banyaknya bangun datar:");
int numShapes = int.Parse(Console.ReadLine());
IShape[] shapes = new IShape[numShapes];
for (int i = 0; i < numShapes; i++)
{
Console.WriteLine("Masukkan jenis bangun datar (pp untuk persegi panjang, l untuk lingkaran):");
string shapeType = Console.ReadLine();
if (shapeType.Equals("pp"))
{
Console.WriteLine("Masukkan panjang persegi panjang:");
double length = double.Parse(Console.ReadLine());
Console.WriteLine("Masukkan lebar persegi panjang:");
double width = double.Parse(Console.ReadLine());
shapes[i] = new Rectangle(length, width);
}
else if (shapeType.Equals("l"))
{
Console.WriteLine("Masukkan jari-jari lingkaran:");
double radius = double.Parse(Console.ReadLine());
shapes[i] = new Circle(radius);
}
}
AreaCalculator calculator = new AreaCalculator(shapes);
Console.WriteLine("Luas total: " + calculator.TotalArea());
}
}

// Interface untuk objek-objek bangun datar
interface IShape
{
double GetArea();
}

// Abstract class
abstract class GeometricShape : IShape
{
public abstract double GetArea();
}

// Concrete class untuk persegi panjang
class Rectangle : GeometricShape
{
private double length;
private double width;

public Rectangle(double length, double width)
{
this.length = length;
this.width = width;
}

public override double GetArea()
{
return length * width;
}
}

// Concrete class untuk lingkaran
class Circle : GeometricShape
{
private double radius;

public Circle(double radius)
{
this.radius = radius;
}

public override double GetArea()
{
return Math.PI * radius * radius;
}
}

// Class yang menggunakan strategy design pattern untuk menghitung luas total dari beberapa bangun datar
class AreaCalculator
{
private IShape[] shapes;

public AreaCalculator(IShape[] shapes)
{
this.shapes = shapes;
}

public double TotalArea()
{
double totalArea = 0;
foreach (IShape shape in shapes)
{
totalArea += shape.GetArea();
}
return totalArea;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v7.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v7.0": {
"shape/1.0.0": {
"runtime": {
"shape.dll": {}
}
}
}
},
"libraries": {
"shape/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "net7.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "7.0.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("shape")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("shape")]
[assembly: System.Reflection.AssemblyTitleAttribute("shape")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
908a15e3ea54bb7a3c1ac4063805d789a3c8b06c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
is_global = true
build_property.TargetFramework = net7.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = shape
build_property.ProjectDir = d:\Datasaya\GDSC\tugas\Object Oriented Programming\Bastian Hendramukti Suryapratama_ITB\
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d1d9aead73d24464710f47616c20b3b712915bf9
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\bin\Debug\net7.0\shape.exe
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\bin\Debug\net7.0\shape.deps.json
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\bin\Debug\net7.0\shape.runtimeconfig.json
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\bin\Debug\net7.0\shape.dll
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\bin\Debug\net7.0\shape.pdb
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\shape.csproj.AssemblyReference.cache
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\shape.GeneratedMSBuildEditorConfig.editorconfig
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\shape.AssemblyInfoInputs.cache
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\shape.AssemblyInfo.cs
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\shape.csproj.CoreCompileInputs.cache
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\shape.dll
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\refint\shape.dll
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\shape.pdb
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\shape.genruntimeconfig.cache
D:\Datasaya\GDSC\tugas\Object Oriented Programming\shape\obj\Debug\net7.0\ref\shape.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4132b45b6d246f4852c2701c861b581cda5e85b3
Binary file not shown.
68 changes: 68 additions & 0 deletions Bastian Hendramukti Suryapratama_ITB/obj/project.assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": 3,
"targets": {
"net7.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net7.0": []
},
"packageFolders": {
"C:\\Users\\bitkomputer\\.nuget\\packages\\": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\Datasaya\\GDSC\\tugas\\Object Oriented Programming\\shape\\shape.csproj",
"projectName": "shape",
"projectPath": "D:\\Datasaya\\GDSC\\tugas\\Object Oriented Programming\\shape\\shape.csproj",
"packagesPath": "C:\\Users\\bitkomputer\\.nuget\\packages\\",
"outputPath": "D:\\Datasaya\\GDSC\\tugas\\Object Oriented Programming\\shape\\obj\\",
"projectStyle": "PackageReference",
"configFilePaths": [
"C:\\Users\\bitkomputer\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.101\\RuntimeIdentifierGraph.json"
}
}
}
}
8 changes: 8 additions & 0 deletions Bastian Hendramukti Suryapratama_ITB/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "bAc3xMK9kHTrxD4iT2OhlG/4eTCiuHgCkZ3Nd07DEpOJwJTuIVAklKrenkqE+zw5wpibh63XEvQT3/HsfScI4A==",
"success": true,
"projectFilePath": "D:\\Datasaya\\GDSC\\tugas\\Object Oriented Programming\\shape\\shape.csproj",
"expectedPackageFiles": [],
"logs": []
}
Loading