rem.pracs
-
Upload
sachin-marathe -
Category
Documents
-
view
218 -
download
0
Transcript of rem.pracs
-
8/13/2019 rem.pracs
1/22
C# Practicals
Practical no-24
using System;
class Rect{
int len;
int bre;
public Rect(int x,int y)
{
len=x;
bre=y;
}
public Rect(int x)
{
len=bre=x;
}
public Rect(Rect r)
{
len=rlen;
bre=rbre;
}
!Rect()
{
"onsole#rite$ine(%&estructor is calle'%);
}
public int rea()
{
return(lenbre);
}
}
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
2/22
C# Practicals
class Prac24
{
public static *oi' +ain()
{ Rect r=ne Rect(.,2.);
Rect r2=ne Rect(.);
Rect r/=ne Rect(r);
"onsole#rite$ine(%rea o0 rectangle1 %rrea());
"onsole#rite$ine(%rea o0 s3uare1 %r2rea());
"onsole#rite$ine(%rea o0 rectangle1 %r/rea());
}
}
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
3/22
C# Practicals
utput-
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
4/22
C# Practicals
Practical no-25
using System;
using System6ext;
using System6extRegular7xpressions;
class pr25
{
public static *oi' +ain()
{
String s=%mar, 8bar, nt9ony are 0rien's%;
Regex x=ne Regex(% :, %);
Stringuil'er str=ne Stringuil'er();int count=;
0oreac9(String st in xSplit(s))
{
strppen'
-
8/13/2019 rem.pracs
5/22
C# Practicals
utput-
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
6/22
C# Practicals
Practical no-2>
) ?nary operator o*erloa'ing "o'e1-
using System;
class space
{
int x, y,@;
public space() { }
public space(int a,int b,int c)
{
x=a;y=b;@=c;
}
public *oi' 'isplay()
{
"onsole#rite$ine(x);
"onsole#rite$ine(y);
"onsole#rite$ine(@);
"onsole#rite$ine();
}public static space operator -(space s)
{
space ss = ne space();
ssx = -sx;
ssy = -sy;
ss@ = -s@;
return ss;
}
}
class test{
public static *oi' +ain()
{space s = ne space(.,2.,-/.);
s'isplay();
s = -s;
s'isplay();
}
}
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
7/22
C# Practicals
utput-
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
8/22
C# Practicals
) inary operator o*erloa'ing "o'e1-using System;
class complex
{
int x, y,@;
public complex() { }
public complex(int a,int b,int c)
{
x=a;
y=b;@=c;
}
public *oi' 'isplay()
{
"onsole#rite$ine(x);
"onsole#rite$ine(y);
"onsole#rite$ine(@);
"onsole#rite$ine();
}public static complex operator (complex c,complex c2)
{
complex c/ = ne complex();
c/x = cxc2x;
c/y = cyc2y;
c/@ = c@c2@;
return (c/);
}
}
class test2
{
public static *oi' +ain()
{
complex obA = ne complex(.,2.,/.);
complex obA2 = ne complex(2.,/.,4.);
complex obA/ = obAobA2;
obA'isplay();obA2'isplay();
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
9/22
C# Practicals
obA/'isplay();
} }
utput-
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
10/22
C# Practicals
Practical no-2B
using System;
using System6extRegular7xpressions;
using System6ext;
class *ector
{
int x,y,@;
public *ector(){}
public *ector(int a, int b, int c)
{
x = a;
y = b;
@ = c;
}
public o*erri'e String 6oString()
{
return(%x=%x%,y=%y%,@=%@);
}
public static bool operator==(*ector * , *ector *2)
{
i0 (*x == *2x CC *y == *2y CC *@ == *2@)
{
return (true);
}
else
{return(0alse);
}
}
public static bool operatorD=(*ector *, *ector *2)
{
return (D(* == *2));
}
}
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
11/22
C# Practicals
class compare{
public static *oi' +ain()
{
*ector u = ne *ector (,/,/);
*ector u2 = ne *ector (,2,/);
i0 (u == u2)
{
"onsole#rite$ine(%ot9 obAects are e3ual%);
"onsole#rite$ine(u6oString());
"onsole#rite$ine(u26oString());
}
else
{
"onsole#rite$ine(%bAects are not e3ual%);
"onsole#rite$ine(u6oString());
"onsole#rite$ine(u26oString());
}
}
}
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
12/22
C# Practicals
utput-
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
13/22
C# Practicals
Practical no-2E
) &elegate "o'e1-
using System;
'elegate int rit9op(int a,int b);
class +at9peration
{
public static int ''(int a,int b){
return(ab);
}
public static int Sub(int a,int b)
{
return(a-b);
}
}
class 'emo
{
public static *oi' +ain()
{
rit9op operation=ne rit9op(+at9peration'');
rit9op operation2=ne rit9op(+at9perationSub);
int result=operation(2..,F.);int result2=operation2(2..,/.);
"onsole#rite$ine(%''ition1 %result);
"onsole#rite$ine(%Subtraction1 %result2);
}
}
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
14/22
C# Practicals
utput-
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
15/22
C# Practicals
) +ulticast &elegate "o'e1-using System;
'elegate *oi' +'elegate();
class peration
{
public static *oi' Print()
{
"onsole#rite$ine(%Ge &el9i%);
}
public static *oi' &isplay()
{
"onsole#rite$ine(%Ge Hor8%);
}
}
class 'emo
{public static *oi' +ain()
{
+'elegate m=ne +'elegate(perationPrint);
+'elegate m2=ne +'elegate(peration&isplay);
+'elegate m/=mm2;
+'elegate m4=m2m;
+'elegate mF=m/-m2;
m/();
m4();
mF();
}
}
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
16/22
C# Practicals
utput-
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
17/22
C# Practicals
Practical no-/.
using System;
public 'elegate *oi' 7'el(String str);
class 7*ent"lass
{
public e*ent 7'el status;
public *oi' 6rigger7*ent()
{
i0(status D= null){
status(%7*ent 6riggere'%);
}
}
}
class 7*ent6est
{
public static *oi' +ain()
{
7*ent"lass ec = ne 7*ent"lass();
7*ent6est et = ne 7*ent6est();
ecstatus = ne 7'el(et"atc97*ent);
ec6rigger7*ent();
}
public *oi' "atc97*ent(String s)
{
"onsole#rite$ine(s);}
}
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
18/22
C# Practicals
utput-
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
19/22
C# Practicals
Practical no-/
using System;
class &emo
{
public static *oi' +ain()
{
"onsole#rite$ine(%Stan'ar'
-
8/13/2019 rem.pracs
20/22
C# Practicals
utput-
Coded by Pravin A.Dherange
-
8/13/2019 rem.pracs
21/22
-
8/13/2019 rem.pracs
22/22
C# Practicals
utput-