[go: up one dir, main page]

0% found this document useful (0 votes)
65 views23 pages

Inheritance, Interface, Abstract Class

1. This document discusses classes and objects in object-oriented programming. It defines classes like Info, Salary, Allowance, and Perimeter that extend other classes and define methods. 2. The classes are used to calculate values like total salary and perimeter of shapes. Methods are defined to input values, calculate results, and output values. 3. Inheritance and polymorphism concepts are demonstrated through these classes, where derived classes can override methods from their base classes. Calculations are performed by creating objects of the classes.

Uploaded by

Adithyan M Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views23 pages

Inheritance, Interface, Abstract Class

1. This document discusses classes and objects in object-oriented programming. It defines classes like Info, Salary, Allowance, and Perimeter that extend other classes and define methods. 2. The classes are used to calculate values like total salary and perimeter of shapes. Methods are defined to input values, calculate results, and output values. 3. Inheritance and polymorphism concepts are demonstrated through these classes, where derived classes can override methods from their base classes. Calculations are performed by creating objects of the classes.

Uploaded by

Adithyan M Nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

INMERSTENCE

ne itente 1sl%e xopexdy0ta Clabs to acaru18t brop o¢


andher (las (t l5al)xol2ezyofo0y9, onguagt

ht Closs tio wnt optsieis oxt inbc<lttel15 (aled


6u ass|xtnt (lass. [Bass (la,
the Class h i e n s t e (yxolp 1 (aned buwulass
deiol Class \ (1lod tto46.

Need tox tvevitee

Conpabt1y toex pyess 4he tov*ittolt e itovsnp 1


YealoYid mocdels.

Keubaol1y.
amettwe viouxe: f Cloh Imels |xopevhrs of
Ovol ie(lons. Thtnaljbuvto46 0t Br uOlt OM to wnitalu
nhett Ope q ofA. Ths 1 Co11edtxmsthnwe.

OCfcYv ttorm5
Sinole Ivshcxttrte. whm abub tlans 1mneyil fom
HiexaxItal innettent
oMy 1a clags.lt 5 Called 61nale lnvnevlemr C

6ub tta5 5,
,
huv tto6 MUt 1tWetinve ittnte:1(omt,thwt mohy vi of mvo1
Bupn Nos;
whm a Guv-tóbs nne vtle, fyo w (lD4t 1n on It-

(ne t , txo w anome (to4,4,.

2Mulhple tn ettwNh buntl ans Iwens


o o w nul hble nne (hon 0nd a1 of tts Vntt tlon
wmthde bost lonet It16 (o 11
vvevtfov 6ngle hast Anr .

A
A
6unylons 0k a tla46 '0bjtE

hut Class tb dekneel tn |va:lavg


0v m 5tmle inveXIttv(e.
Jano alto0s
CMIortn1 ml,nulhtaNd) dls
Wht mans that tlobs hos oatioh Hl meollat
Sulrlas.
avnetye lAas (dtxwe a

next

ceWco (loG5 Nt (Ytate% tos5 ontlh


nabe (lal
6 Colle derwed (Subtlas5 |(nilodtla4s|
entendma tla>

AbpMcnhos 0 nneyltaml
Itwlenent Xt useab1luof (loufes
¥ t ato s to wwllewoe nt 0
Abe momtiF lwam
hexahous a
&hMentendb kmuosd:
th1s Ktmooy x wat e H dloesnot auo uo ettnhon of memb

1c deYwrdtlass
hast (la45 by
t Y6 met Vods of ts owv (la4 6,
dyntan
class deYweeltla45 vmamt ettenods xo tetteed
pnbe (la45 of mtmbers Of hast
(las5 hy nen- dex wtod rlons
V1Sibilt m ocde
hu m 'w hrs m e t h od.

ne funthonnat (ovntxols aNelaith


and attt%5 of wmt be x6 of vaie (ln6 oy
oleYWeol tOGS , 16 V1SI111u mode. Dem tlase bastPxo aned a clexweA tlas
devo +o find pxvdutt of 2 nos
het onxt 3 fps
uwli1
xwatr
xotHed, flo at Naxioo1t.
2

ttalo0h 0Memhon of mo
ow bexs ME
Votd entty):lnput Kn2
dceo t lass Voe h o ) d1elp1y d2
P
7
Defne supesllass no and buntlas balayu
lwbovt jana-uhl. *;
to tnd hotal bala
(last namt :Imfo.
IN: nomt nt Sala
Sala VOId (ttloE)
MF
NO1d ActpE) "); 4op1"an d6alai
50pl ( Ente nawme

Void snovol): hame61 n t U n r ) ;

Cl Lh namt bnlary
Nallouoan te
to tal
MP Notcl to ute to (olmlete A11ouoammt S0pln nam : "ana t )

11l 6alaYy bo pl " 601AY) :" J6al);


f 5alaÝY 2000o

btbe ALe
Calmtat 4 talalaxu wox |aNa.um1.
Ctan 5alaxn entcnds In fo.

Aole A10wanlt
Vo1e diplom t): Dk doun le FoFa1

Void (0 nlutt )

Aceeht L)
(6atn 2 o0o) (onstXntox lmneztame:yotChs 0f 1n vok1no
Constz toy 0 5u/2¥ {la55| a b t (lass
G1O mlt (1.0 to0.o)*6al; w i n fonst Yul(-o? of cexwettasy t l4no
fonstXuloy ivn ntsltenle

C11Ou Cnle 0.0,

tot a)= Cal +q11o ont t

bymtar-"1o inmtyiE delauie ronstrn itoY


Moe dspl ont)
Of6np (lats witw edtyWeel tlass
not);
opln btal-"+tp tat); Syntan o inne i t haromn ttt m2'd
op ( Amo ntt+ amo mlt (ovbtnroY 0f 5ultY a s e ((as«

hm)tME

1 Y 1 Ob -itm olavnt)
oD. (ownpute1);

ov.d15plownl)j
fmhox |awa.u H1
d= d c

Styin na autnoY
votel fine
elounir | r e
(1YaYy(Sting ,**Yivgp
counle nb) (dk= s)
2. o0;
(d>5 LE dz =10)
el6e
utv0 = 3 .o0
el
5 00
Vo1Asol)

Noid di6 plom)


Sop1n ( N a e " v amt)
soplm ( " e e : " - pYue); Snou) day"- A
601p1( Nuwht O4 t t y s
5opl (" Fne ="+Y);
(lnes (om ute eotttwdb un day d onol e tamt =0-0;
tannt= (0-02 * p* cd)+XS
50pln(Awount tone Pe=tat);
t t dj
dounlt X
Conptr (5txmqn, 54x mq a, douwie np, Int ded
d ouwte X)
has e t ) deince to
44uxY (lonn6 þexiwe4cY imlyox janna.uhl. ;
Clalate pes'imtteY 0 naxalteloq¥a and
5untlab5 axtn +o (Almlate axta 0 paxa1ttl0qra
donnlt O
Clss: Peviwnttt Y toy\ dounic
e n tteY (dounle aa, do untt b»)
A:ltnat im detiwnal
oxead hw.

Mt eY Funthon
PexnnettY( . . ) oxawoete(12eo dounlt (almtatt )
Contut tor.
dounle (al ulott F 2* (0+) t a dounle (all = 2¥ (atb);
Vod snou t) - Xtwxn (all

Clase nomt : Axea .

NO1e 6nol)
Systrw. o Utt pmtin ( tgintt*+ong1n
en- Systean. 0nt 17Y1ntln( "Bead th:"+
MF dount 5oplv ( Pevimtt " o);
Axea .) = tAlnatt 0 ;

vord doaxcal) (bxn)


Voio 6now ) CLabyAta ?3tttn ds beY1mttt

dounle n:
dounte axt a

b, douie ir
Axea (aounie o, clouole
amnle of (om hile
hme o oxpn16m

ths hhe m ust he


Same (dfest nt eamt.
OvCYYIdiimgIE A
huv tlohs |deyNt dtlo45 han tne

5awne wmtimnd ob dctlaxed in nose Clabo h r


fnniton deywed tlGy 15
sa1d to over'd
h aYXanoheMent known s tuntho oveYYIdug

Dh-ccemec hthoeem wtnod Oveonsim and vo t4¢ * un tmo


10 oveYtowme Odeytdin n

eNYelm bubey| bnhe (lass thc snpey 14twoxd 1 uatd 1


t fomoomq foxwmat
Ovryl caolimgs
&ulpex. fa honnawt );
y ANO ofmtmods axc A No: of mttmod5 eg Suptr 0wplay (
dfmco ttn 5ame ost dehnt wh1
d Cla5 name :shhdtnt
(tALS N
Mame,dobixtm- StY1n
ht ONegloaod1n memool Ove Yiololtnnmtthols
vO1dnl7ntdata t)
m m hotr5st5
-

ME
Sní1a e oe Void n t data l)
Ctas namt: max4s.
Vo lznt data )
stan(e NnXlablts
tvtal, pev: AAnou 60pln( Namt MawMt) 5015 ( o
:Cxndt
Sopln ( 00"+dooxw); no:

95 A
Ct065 mayks CitEend .6mdem
6o&kk< 95
>Ho L 60
doun Ic ot, ey; StoiMCY 5( = mtwh tavnt(614
Votd Sea d dntnU)

ME 1nputdata);
+ot =
5(.netE1Do uwl);
Noid eacd data l)- tdtal mark 600
Void (ompute () Votd (om hute ()
Vot 6hoo data (:
peY= t t a (tot |500) 10o;
f (pex >- 85)
(la46 5hdent

5tina mamt, cdoiym;


nt o ; 6tanntY 61= MtwstamtY (4ystumi. ele 1f
(bex> G o && ey <5 5)
Voiol tnput datn) Sapa(Gnd qd 1
elstt oex>=M0% yex<bo)
5opln Entey name aned DoB"); G0ptoa("am gd="t'
namt 50.nePline (1 e1sc
dobyt :5(.motlin )} qed-D
ON5.mextlnt()
Ci

Norol Cno) datal) ox 1a.uht ¥;


vntodatal); Ct06 Cmblogee Data
Sohn(Gxade "+9d);
5opinheY(tntagc"+pev) (nt ewb Codt
dounle hasiu ha

Cmployee Data )
(t64 amt Gmployee odata.
nstanle NaX1anlrs |IN ewmbtode 0,
?mbtodt: imt; employee DataC)
on ay: douvlt
emptode = 0
Mtmt Y funthow
habu h a °
em10etodata t)
emptoyee datalint/, dounle cd) enpioyet Datal nt(, mt cdonolt h )
Void smt ()
wmptodt 0
(lans hme OveYhme
days no:of doys worl4tod estt yo.
Satt: 8ate| dom . Void hrvt )

Mtbty FuntHon
0pln " mhloyet Oata :"+ Pmprodlt)
0Nerhmt(. . . . ) 60pln (" 3ante |5an:" + nas1t1a
lonvne almatt-6a|) -tot5a
Iwmoxt lonl autl¥; CIab vMame: Vlnme
(Ia6 0tY hwat entndh tmploy Dat
In 91
Int nodavs;
nt
dounic &at; Plane (. . . )
Ovey hwnt tnt ,douolt d, imb no doys, doubit Y) Notd 6nov ()

5nt) Cla mame(IX(1

6nlptxC cl); 02
n-noday
att- -.)
Votd fnd hadn 0)
dounlt almtatt-Sal) Vod find Axea ()
01th &A = ndays + ( Xatt) A VagiLGa\ONX Vod 6hoW)
Inl)oxt 1oNa.uh ;
(1an5 NMaMM (Axel. ettn td 9\ome

Void vo6a10) {
Yinr);
m2,2
(Ile(inl 1,Imt u1 ,imtot,tmy, )
5o b alla te-5a1());
SnbrY( , 1 )
2 ( W2
Xad u 0 . 0 A3ta:0.d
2 2
Vod find Radus) Abstxat (la66

ndwns M a t h -5Yt (Ma o.po vo ( (2 -o(). iht (la4-AVmtaltovie drtlaxahon o t nout

MOH 1o ((o2 )1) 2 anstial t t hons an tordttb utl64


to detine anshxal tho
Votd fm dAx ()
t wmoedhex kemuoosoverott thund ot Por
aXtn 3-14 Zocdus X0dM; Clabbnawt to Make ttanotaatFclahs and s i l
anbtsatt 1usl e Hox finho tt be towntb
VO id shDl) abstxatt tuho.

61 ptY.5no uol), Sunton anst at Clo vame

XndnA t)
50pin (" Xadus "

60pI 91tn" Area)

1o detlax fumt thon a s ovstxat wmtbon


anbtntF mtho) data hy1pe wntho nnmt ) :
)Defhne ay avstXatt kybe SubeY(lh6s Spnert mhox oa h1.
ane Suntlas6 aaca.

doublt Xndn
v:
Spneye (do ublt y
nAns: Y»elius1 deunal.
MF: aeltne Y;
S1phty (donwlt );
avshal vod tobute Axea ); anstxatP VOd CowlputNotttnt ();
avnsta l F vocd (owm|nte olM we t) abtyatFvor (ow hmtt Ascat);

ClnsatHxen. (LA Axea ettenels b}neyt


.

douwle oxtn
Vot: douvlt Volut
MF Axe1 ( dounlt, 9
Axt(. .) .
-

anstYat Vooltom|putt Ayea)- Sap Supex ()


anstxalt 01 (omnte Volume) axeao
N0wme 0.0

Ansa (ompnte Votume )

VOnmt
Sopl votwme: Nownmt)
22
30 ",1

RbBiM (onnlputt Axea)


h m.1)
e a h X 3-M Xaclub x Xadus p) pln 61)
Ve hopln"Pxea:"4AYC); 30 2

Gcld Bech unbe


G101dBas(w No
buwttt NoielmaIn ()1ows |nlvl Mitmat (
I povt ava-uhl.; txtep tev
(lass GiotelastnNo
1b n Stamnt S: nw KtanneY (&ysttvm 1m);
nltc 6tahe boolta (inFn) 50n("tntty nuumne") ;
nt n:6t.netl t ():
f (.2 - o)

turn-fat-e fox(ivnti=3, en;+)


fov(inti 2;icnla;i++) f (16/pawn()EE 1pamn((n-i)))
f(.1o) Soptno(ia +(n1)
thhm alGt

chuYnxue else
Sopin Invald inhut");
Jefine avn abbtxatF hype Suþe? (la% 0bjett
sthne VaYlavle Clas Noluwm ectevads 0v]eu
douwlt :
doule h a n ,
Onet(douwle ddms) c oule Vrone

anstyatE Vold (omeNo t(,) douwlt Mtm


anetxatt Noiel tMlmle Nott) Not e ( douwtt * , cdoui e n)

Cass non Volmot


balpex( *);
Ntone
VoI tont Nol)
Nolnwel. )
aobtxatt Vo1d (ome1o1 C) vCoe (1.0 | 3.)* .3* xaY *
ht1gmt
avstxalt Noiol Vo\()
ulietY so1ple ( (ove Nolmme -"+Ntome);

mpoY oNA.uhl-¥ Yot taytmdea vot()


alb bas (1056 0Vjett
ylnelY- 3 TM * *nen9 nt
Aouble 6o1p lVotuwme ef aflnedtY- "4 Nuflu
Obett (dounlt Xadw)

anstyattvoel(ont Voit)
abshyat Voi tloleyvo1()
clAS5MA

rnqt o4 Xadim tct 2 hCims (clouwlt


3t
1y cho
unt2)
Pomt

Class:Pont (anetyaih hyoe) 2 t2


nbtanlt Naglov1t anstXatE v o i d n d D s t a n t t ( ) ;

Noil Find MIl[o1nt


avstair 01e hnd D1e tanne () anstat

No1d s ho w l )
Voie how )

(lns ome di6tamle. 60pl("2t:"+71) ;


o2,z bo1p1n ( *2:"+ 2);
cston-5t0xe \tmglvM of xaelms ttnds DoiME
Clabs olts-antc
midom 1d e) midpom
MF douvlt 2 donw d1t
wiol donolt m ted y
dtamte. . -) donle 2
douvie

(t (douwle n ) ) dDuele n y,dowle


tom
2 , dounle 2)
twlo na.Unhl-*,
Onstytt\A4 PoinP
douwle n t'
dounit 1 disto0
midx 0-0 M10 0-0
Absrxar vu
Votd ftvd ctan (t)
(ontan , and derlonahov of ahs'(otPh,ho
MAI.60yt ( (marboo(-, 2) + hunlr fa thens 0 n 1 1trft
Malw (9.)u2)2-9;
(t1 Nov- bYaitq hv data y t .
An ntrxfart tn 1onial nluthiat of'o tinh6
(tnas tutnr (ovns tan and anutvatt notood
Vo1 mid point ) They kuMonre 'intryfatr' , dur ko dotio re
an 1ntl{htr (lan.
w ot,+*2 )]2
wnd -(1+2)12; o t r f a t e NavOnlty at ny d foult,
ounltt btahra nd tin nl aned M0 , G
Yoio how )
nl1t Aned anstlt

sp6vupt. 4o w); Suyntan - 1mtexfalt vawnt- of -ntrlo t


Sopln (m 1el poi " **xd)
Gopi ( miodot** "4 mid y);
5opln ( dtamte =dh6) Ivnpttme ns. Uas 1ot inneths r tn trrlo tr 16

byntan: (lo65 (lansnamt ettends hnhr


(
(Lass a m e 1 )lean 1nrfa vamn

o a nne
Imo& jawa. uhl¥
InttxBat namth : 5ha|s KMA inica-la t 6hapts

ME:
xey?n5t a x a of doavltadca ();
oule (altAxeal):
Sna pe lmwn)pl ewevms Shate
Ctas5 5}phexe
5p
dounle Xadus
( doastç x)
admb 5 hhext

adimse X;
ME
Sbet (dounti *) doumlt
dounlt (alaxlat):

doule ax HY 3 H* Xacl1ms * Xadn


Clos todY
V:

ne1gn
CLasb mlmott Implttn l55habes
MF dounlevMeignt,
thvnelt ( doutt Y dlmolt ): cou I 2acd;
edou (n1LA y tn t): dounlen)
Xaod=

heplt ounlt (ale Axea )


xehay (N¥ 2 x 3-1H * ad } he9nt); {
D1Pf
Intente.
abstyat
An abstYat- (lab6 An mtevfart toay
Ct tnd ovny 1tt55 ettend any no: o
tntfate at a hm.
ans tyatt (las at

I anstYatt(l445,Kmuood¥ n an IntcYtate
Anbt Yat1 manelaFoyy Aeyuord anett t1
t derlaYt tyalt OpHonal to del1oe

tyt metheo avst Ynl metno d .

An abstyatt (las5 (an Y An teyfattlov)


nowt et rupt of howt punit
memodS, it ayhaut anstyatt metno
Amo tovn&RAte ( on
yWat-)
MA

M od

(onve
Mtnt&- wmttm od Me neY-mtMod ta
6what 1 mtefate -7 Ho 141ntetate 1 ditCe
t a (ta5 havmtand fxrnt
towm (lans
xo (lC5.
ubtd to 1nthali2 nome and tt Mitd
OM 0f Ctass.
lntefate Class pexfoywm parhrvlaY
4 10 V1ual (onst A (labs tan h
that st þy¢stnlsa stan hateol ln Foa
qYoup of twtytes. no:0f ooie tls ond
Jhe enhYit iwmam Mas (onixut toY'of tk
tylr
be elato /mt th otdA5
tyl
An intcy-fatt Cannot 6) Fottouo i g finnt ho l hart ofn (tohs
e tntoavhatr d to
Deftvmthon. n d ovnout Nhen n =Iand n
19. Io.
objert and dorhnot
hNe ay
Conshgl to Y t moqntfinn ( 1tn)
t: o)
trvho
m a a o w (nl ) * 10 4 . 2)

You might also like