Skip to content

Commit

Permalink
Add .net files
Browse files Browse the repository at this point in the history
  • Loading branch information
sthsuyash committed Feb 6, 2024
1 parent b93f943 commit 4ffaab1
Show file tree
Hide file tree
Showing 12 changed files with 954 additions and 0 deletions.
399 changes: 399 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions 6th_Semester/NET_Centric_Computing/C#Basic/C#Basic.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34511.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "C#Basic", "C#Basic\C#Basic.csproj", "{E00787D2-39D2-49F9-A224-9C52C33F0694}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E00787D2-39D2-49F9-A224-9C52C33F0694}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E00787D2-39D2-49F9-A224-9C52C33F0694}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E00787D2-39D2-49F9-A224-9C52C33F0694}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E00787D2-39D2-49F9-A224-9C52C33F0694}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {770D7910-7754-4B72-8C46-682182B235D8}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions 6th_Semester/NET_Centric_Computing/C#Basic/C#Basic/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
45 changes: 45 additions & 0 deletions 6th_Semester/NET_Centric_Computing/C#Basic/C#Basic/Box.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System; // basic input output commmand

namespace C_Basic
{
class Box
{
// instance variable
private int length;
private int breadth;
private int height;

// constructor-> initialize the instance variable
// default constructor: w/o parameter: public
public Box()
{
length = 0;
breadth = 0;
height = 0;
}

// parameterized constructor: parameter value provided
public Box(int lenth, int breadth, int height)
{
this.length = lenth;
this.breadth = breadth;
this.height = height;
}

// method: used to provide some services
// method: without returning value
public void area()
{
int area = this.length * this.breadth;
Console.WriteLine($"Area of the box is {area}");
}

public void volume()
{
int volume = this.length * this.breadth * this.height;
Console.WriteLine($"Volume of the box is {volume}");
}


}
}
59 changes: 59 additions & 0 deletions 6th_Semester/NET_Centric_Computing/C#Basic/C#Basic/C#Basic.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E00787D2-39D2-49F9-A224-9C52C33F0694}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>C_Basic</RootNamespace>
<AssemblyName>C#Basic</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Box.cs" />
<Compile Include="Constructors.cs" />
<Compile Include="Inheritance.cs" />
<Compile Include="MethodOverloading.cs" />
<Compile Include="MultilevelInheritance.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Rectangle.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
53 changes: 53 additions & 0 deletions 6th_Semester/NET_Centric_Computing/C#Basic/C#Basic/Constructors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;

// constructor of super class cannot be called directly by sub class
// to use the constructor of super class, we use base keyword

// base keyword is used to access the base class members such as constructors, methods, and fields
// it uses:
// 1. to call the superclass constructor
// 2. to access the overridden methods of the base class(overriding)
namespace C_Basic
{
class Parent
{
private int x;
private int y;

public Parent()
{
Console.WriteLine("Default constructor of parent class");
}

public Parent(int x, int y)
{
this.x = x;
this.y = y;
}

public void add()
{
Console.WriteLine($"Sum: {x + y}");
}
}

class Child : Parent
{
private int z;

public Child() : base() // calls default constructor of parent class
{
Console.WriteLine("Default constructor of child class");
}

public Child(int x, int y, int z) : base(x, y) // calls parameterized constructor of parent class
{
this.z = z;
}

public void square()
{
Console.WriteLine($"Square: {z * z}");
}
}
}
85 changes: 85 additions & 0 deletions 6th_Semester/NET_Centric_Computing/C#Basic/C#Basic/Inheritance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
// single level: only one parent A->B
// multi level: chain of parents A->B->C
// multiple: one child can have two parents -> not possible due to class -> only possible using interface

namespace C_Basic
{
// single level inheritance
class Employee
{
private int id; // this is auto implemented property -> no need to create private variable
private string name;
private string address;
private string department;

// method to initialize instance variable
public void setEmployee(int id, string name, string address, string department)
{
this.id = id;
this.name = name;
this.address = address;
this.department = department;
}

public void getEmployee()
{
Console.WriteLine($"Id: {this.id}");
Console.WriteLine($"Name: {this.name}");
Console.WriteLine($"Address: {this.address}");
Console.WriteLine($"Department: {this.department}");
}
}

// teacher is a sub-class of employee(which is parent)
class Teacher : Employee
{
private string subject;
private string qualification;

public void setTeacher(string subject, string qualification, int id, string name, string address, string department)
{
this.setEmployee(id, name, address, department);
this.subject = subject;
this.qualification = qualification;
}

public void getTeacher()
{
this.getEmployee();
Console.WriteLine($"Subject: {this.subject}");
Console.WriteLine($"Qualification: {this.qualification}");
}
}

// multilevel inheritance
class PartTimeTeacher : Teacher
{
private int hours;

public void setPartTimeTeacher(int hours)
{
this.hours = hours;
}

public void getPartTimeTeacher()
{
Console.WriteLine($"Hours: {this.hours}");
}
}

class FullTimeTeacher : Teacher
{
private int salary;

public void setFullTimeTeacher(int salary)
{
this.salary = salary;
}

public void getFullTimeTeacher()
{
Console.WriteLine($"Salary: {this.salary}");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;

namespace C_Basic
{
// method overloading refers to two or more method
// having same name but different parameters
// method overloading: for polymorphism // static polymorphism
// no of params or data type of params
class Calculations
{
public void calc()
{
Console.WriteLine("This is default method");
}

public void calc(int a)
{
Console.WriteLine("This is method with one parameter");
}

// if number of parameters are also same then their data types should be different
public void calc(string a)
{
Console.WriteLine("The value is: " + a);
}

public int calc(int a, int b)
{
return a * b;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;

namespace C_Basic
{
class TwoWheeler
{
private int reg;
private string name;
string model;

// properties
public int Reg
{
get { return reg; }
set { reg = value; }
}

public string Name
{
get { return name; }
set { name = value; }
}

public string Model
{
get { return model; }
set { model = value; }
}
}

// class that inherits TwoWheeler
class Bike : TwoWheeler
{
private string color;
private double speed;

public string Color
{
get { return color; }
set { color = value; }
}

public double Speed
{
get { return speed; }
set { speed = value; }
}
}

// class that inherits Bike
class ElectricBike : Bike
{
public double range;

public double Range
{
get { return range; }
set { range = value; }
}

public void getElectricBike()
{
Console.WriteLine($"Registration: {this.Reg}");
Console.WriteLine($"Name: {this.Name}");
Console.WriteLine($"Model: {this.Model}");
Console.WriteLine($"Color: {this.Color}");
Console.WriteLine($"Speed: {this.Speed}");
Console.WriteLine($"Range: {this.Range}");
}
}
}
Loading

0 comments on commit 4ffaab1

Please sign in to comment.