Da Moe Employe

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

DamoeEmploye.

cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace class_work
{
class DemoEmploye
{
static void Main(string[] args)
{
RegularEmployee E1 = new RegularEmployee();
RegularEmployee E2 = new RegularEmployee(1,"shakeel,","Bahawalpur",40000,3000,5000);
CommissionEmployee C1 = new CommissionEmployee();
CommissionEmployee C2 = new CommissionEmployee(1, "shakeel", "Bahawalpur", 40000, 500);
Console.WriteLine("E1 objects;" + E1.ToString());
Console.WriteLine("E2 objects;" + E2.ToString());
Console.WriteLine("E1==E2" + E1.Equals(E2));
Console.WriteLine("Earning"+ E1.Earning());
Console.WriteLine("Earning" + E2.Earning());
Console.WriteLine("C1 objects;" + C1.ToString());
Console.WriteLine("C2 objects;" + C2.ToString());
Console.WriteLine("C1==C2" + C1.Equals(C2));
Console.WriteLine("Earning" + C1.Earning());
Console.WriteLine("Earning" + C2.Earning());
E1.EmpId = 12;
E1.Empname = "shakeel";
E1.Empadd = "bwp ";
E1.BasicSalary = 50000;
E1.HouseRentAllowance = 2000;
E1.MedicalAllowance = 2000;

Console.WriteLine("E1 objects;" + E1.ToString());

C1.CommissionRate = 1000;
C1.TotalSales = 100;

Console.WriteLine("C1 objects;" + C1.ToString());

Console.ReadKey();

}
}
}

Employe.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace class_work
{

abstract class Employee


{
private int empId;
private string empName;
private string empAdd;
public Employee()
{
empId = 0;
empName = "";
empAdd = "";
}
public Employee(int id,string name,string add)
{
EmpId = id;
empName = name;
empAdd = add;
}
public int EmpId
{
set { empId = value; }
get { return empId; }
}

public string Empname


{
set { empName = value; }
get { return empName; }
}

public string Empadd


{
set { empAdd = value; }
get { return empAdd; }
}
public override string ToString()
{
return "empId:" + empId + "empName:" + empName + "empAdd:" + empAdd;

}
public override bool Equals(object obj)
{
Employee E = obj as Employee;
if (empId == E.empId)
return true;
else return false;
}
public abstract double Earnings();

}
}

RegularEmployee.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace class_work
{
class RegularEmployee:Employee
{
private double basicSalary;
private double medicalAllowance;
private double houseRentAllowance;
public RegularEmployee() : base()
{
basicSalary = 0;
medicalAllowance = 0;
houseRentAllowance = 0;
}
public RegularEmployee(int eid, string ename, string eadd, double bs, double ma, double hra) : base(eid, ename, eadd)
{
basicSalary = bs;
medicalAllowance = ma;
houseRentAllowance = hra;
}
public double BasicSalary
{
set { basicSalary = value; }
get { return basicSalary; }
}
public double MedicalAllowance
{
set { medicalAllowance = value; }
get { return medicalAllowance; }
}
public double HouseRentAllowance
{
set { houseRentAllowance = value; }
get { return houseRentAllowance; }
}
public override string ToString()
{
return base.ToString() + "basicSalary:" + basicSalary + "medicalAllowance:" + medicalAllowance + "houseAllowance:" +
houseRentAllowance;
}
public override double Earnings()
{ return basicSalary = medicalAllowance / 100 * basicSalary + houseRentAllowance / 100 * basicSalary; }

}
}

CommissionEmployee.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace class_work
{
class CommissionEmployee : Employee
{

private double totalSales;


private double commissionRate;
public CommissionEmployee():base()
{
totalSales = 0;
commissionRate = 0;

}
public CommissionEmployee(int eid, string ename, string eadd, double sales , double commission) :base( eid, ename, eadd)
{
totalSales = sales;
commissionRate = commission;

}
public double TotalSales
{
set { totalSales = value; }
get { return totalSales; }
}
public double CommissionRate
{
set { commissionRate = value; }
get { return commissionRate; }
}

public override string ToString()


{
return base.ToString()+ "totalSales:" + totalSales + "commissionRate:" + commissionRate;
}
public override double Earnings()
{
return commissionRate/100 * totalSales;
}

}
}

Calculater.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Media;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace calculater
{
public partial class Form1 : Form
{
bool dotpressed = false;
double var1 = 0;
string arthoperation;
bool operaterpressed=false;
public Form1()
{
InitializeComponent();
}

private void button14_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" || operaterpressed == true)
textBox1.Clear();
operaterpressed = false;
if (((Button)sender).Text =="."&& dotpressed==false)
{

textBox1.Text = textBox1.Text + ((Button)sender).Text;


dotpressed = true;
}
else if (((Button)sender).Text != "."){

textBox1.Text = textBox1.Text + ((Button)sender).Text;


}
else SystemSounds.Beep.Play();
}

private void textBox1_TextChanged(object sender, EventArgs e)


{

private void operator_click(object sender, EventArgs e)


{
switch (arthoperation)
{
case "+":
textBox1.Text= (var1 + double.Parse(textBox1.Text)).ToString();
break;
case "-":
textBox1.Text= (var1 - double.Parse(textBox1.Text)).ToString();
break;
case "*":
textBox1.Text= (var1 * double.Parse(textBox1.Text)).ToString();
break;
case "/":
textBox1.Text= (var1 / double.Parse(textBox1.Text)).ToString();
break;
}
}

private void button13_Click(object sender, EventArgs e)


{

private void button11_Click(object sender, EventArgs e)


{
var1 = double.Parse(textBox1.Text);
arthoperation = ((Button)sender).Text;
operaterpressed = true;
dotpressed = false;

}
}
}
Notepad

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp12
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void newToolStripMenuItem_Click(object sender, EventArgs e)


{
richTextBox1.Clear();
}

private void openToolStripMenuItem_Click(object sender, EventArgs e)


{
OpenFileDialog opnfdlg = new OpenFileDialog();
opnfdlg.Filter = "Text Files(*.txt)|*.txt|All files(*.*)|*.*";
DialogResult dlgrslt = opnfdlg.ShowDialog();
if(dlgrslt == DialogResult.OK)
{
richTextBox1.LoadFile(opnfdlg.FileName, RichTextBoxStreamType.RichText);
}
}

private void saveToolStripMenuItem_Click(object sender, EventArgs e)


{
SaveFileDialog svfdlg = new SaveFileDialog();
svfdlg.Filter = "Text Files(*.txt)|*.txt|All files(*.*)|*.*";
DialogResult dlgrslt = svfdlg.ShowDialog();
if (dlgrslt == DialogResult.OK)
{
richTextBox1.SaveFile(svfdlg.FileName, RichTextBoxStreamType.RichText);
}
}

private void exitToolStripMenuItem_Click(object sender, EventArgs e)


{
Application.Exit();
}

private void cutToolStripMenuItem_Click(object sender, EventArgs e)


{
Clipboard.SetText(richTextBox1.SelectedText);
richTextBox1.SelectedText = "";
}

private void copyToolStripMenuItem_Click(object sender, EventArgs e)


{
Clipboard.SetText(richTextBox1.SelectedText);
}

private void pasteToolStripMenuItem_Click(object sender, EventArgs e)


{
richTextBox1.SelectedText = Clipboard.GetText();
}

private void fontToolStripMenuItem_Click(object sender, EventArgs e)


{
FontDialog opnfdlg = new FontDialog();

DialogResult dlgrslt = opnfdlg.ShowDialog();


if (dlgrslt == DialogResult.OK)
{
richTextBox1.SelectionFont = opnfdlg.Font;
}
}

private void textColorToolStripMenuItem_Click(object sender, EventArgs e)


{
ColorDialog opnfdlg = new ColorDialog();

DialogResult dlgrslt = opnfdlg.ShowDialog();


if (dlgrslt == DialogResult.OK)
{
richTextBox1.SelectionColor = opnfdlg.Color;
}
}

private void textBackColorToolStripMenuItem_Click(object sender, EventArgs e)


{

private void fileToolStripMenuItem_Click(object sender, EventArgs e)


{

private void textBackColorToolStripMenuItem_Click_1(object sender, EventArgs e)


{
ColorDialog opnfdlg = new ColorDialog();

DialogResult dlgrslt = opnfdlg.ShowDialog();


if (dlgrslt == DialogResult.OK)
{
richTextBox1.SelectionBackColor = opnfdlg.Color;
}
}

private void richTextBox1_TextChanged(object sender, EventArgs e)


{

}
}
}

DemoPoint x coordinate y Coordinate


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DemoPoint
{
class DemoPoint
{
static void Main(string[] args)
{
Point P1 = new Point();
Point P2=new Point(10,20);
Point P3= new Point(20, 30);
Console.WriteLine("P1 object:" + P1.ToString());
Console.WriteLine("P2 object:" + P2.ToString());
P1.SetXCoordinate(25);
P1.SetYCoordinate(35);
Console.WriteLine("P1 object:" + P1.ToString());
Console.WriteLine("P1 object: xCoordinate:" + P1.getXCoordinate();
Console.WriteLine("P1==p2 : " + P1.Equals(P2));
}
}

Point.css

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DemoPoint
{
class Point
{
private int xCoordinate;
private int yCoordinate;
public Point()
{
xCoordinate=0;
yCoordinate =0;

}
public Point(int xCoordinate, int yCoordinate) {
this.xCoordinate= xCoordinate;
this.yCoordinate= yCoordinate;

}
public void SetXCoordinate(int xCoordinate)
{
this.xCoordinate = xCoordinate;
}
public int getXCoordinate()
{
return xCoordinate;
}
public void setYCoordinate(int xCoordinate) {

this.yCoordinate= xCoordinate;
}
public int getYCoordinate()
{

return yCoordinate ;
}
public override string ToString()
{
return "XCoordinate:"+ xCoordinate +",yCoordinate:" + yCoordinate;
}
public override bool.Equal(Point P)
{
if (this.xCoordinate == P.xCoordinate & this.yCoordinate == P.yCoordinate)
{
return true;

}
else {
return false;

}
}
}
}

You might also like