Aoop Ha-2
Aoop Ha-2
Conclusion Jn this
pattn se take shape as inerace By ustng
inteace we irplenented 4 clan by ustng trnplemerda and
we oveiden bne mesthod drwer()
Output
Dnatde Reckange
Tuyide Sauane
Gnstle Pourdad etorele
Trsde Poundedquoe
920003010
)
Adaglen dean patton
Descxiption!
In this patlenn t o ungeloted objecty woars togehen.
""The obje tha can loin tuoo unselated object, is called as
Feapler design paton and tt cormes urden structnal desin paten
"Th tits attro of paokern ue need to implement înthe 2 oa
WVolt clan ohich is used to meose vot.
ii SocKet is wse to contant is pooduced 20v.
Rlock diogram
Volt
volt
getvotl)
getvdt)
Eatend Secket
tget VotC
Socket Adapter
get i2ovotsC)
Sockt elo Adaghe get (2volts)
Jet 3 vot)
3et 12v
gef Bv/convendvolt Main
Tmplemets
Maint)
2200033070
nplernerkation
clax Vo tt
prtvte tnt vo tt;
publie vod (intv)
thes. volt =Vj
publie int get volts C)
{.
netoun vots;
pubte void setvolt Cint olt)
this.votto vottj
clan Socket
outputy
The output o Dov 120
the outpt 2v 12
the atput 3v:3
22000230t0
matn
FJava
9teowCe
-test
-java
opernaing
Sn puo ue h e to name voable clowses, methody et
hence shoud aoay geve them a name thot they an belath to
whitespace, and îndentatiorn
cohitespace can help you make pun cade vey seodabe that is
ohy it adised to add ohtespaces toheneve
you can odd tham.
Code Smelu
Code Smel ne not the kas tte
proganoth code Smell
to0 youn pxcpam mtdht, coonk juut finehey do not prevent
dhe proqam fiom funettontn or are fneomect They jut
or
Sgnity hke oeaknes n detqn and miqkt inçreales dhe sK
or buqs and pxoamfarlre on the felune.
"Types ef code Srnelly
(nuoithin clams
Sy ketuoeen claes
úy code amelt idhin clanes
Cormment yes, cornmert one Code Srnell too B like deodat
to the code J! emmerde eiglan feso ines ef complkx code Cony
compex euenion
qmhod Along methad tontatny too many ltoes o! code.Any
Code uotth moge han l8 iney shDud make you Quest (on
2200032040
ACode smel betoeen clael
Oata elames A clan hat jut stPed da and no methods.These
elanes don t contain any dunction aty
Data cumps-Data that lo ky Sini l aybe belorgs 4o dhe Sne
clan.
Dadoctorirng technigu
Qefactoinq encompases a number of specifte code hygiene
paartices " when it comes to eliminatig code Smelly haoever,
there ae thuree patiulanly etfectie technia!
Composiog Methady
"The tecntque ,cornposing aims to eliminate sedutat methedy
"here re two distinct ooys developes Coan do fis
Srplefing methody cal
"The next techni¡e s to mpf mesthod calethat ovetime
have becorne busied io Jage amous ef code that ore
daunting to uok oith pOamey have Seveolnys to
Ermey melhod caly.
2200o 330o
tlahset
Hahset s a lolernentotion canu. of set
" Set act os aran set 8tore gHoup f objeey
No dupltctt values ve allouoed
" Oden caunot be paredicted.
method e! hashset:
boolean add Cobj E)
,) vod clean c
N) boolean Cortainn (obi)
ivy boslean sErnpy U
cM) tnt sne)
iplementation
clats ash getDemo
publte statte void main String ags)
Hashset sting hs=neuo tashset<string))
hs add LTndio);,
hg. add Canca)'"
ha. add mni ea ");
hso addDndia);
terator.ite hs iteraton 0;
ohle Cit hotext){
>ero out. pritla (itarnext L1);
india
Caradda
set)) printn break;
shet<string>c); keugetC)) out h3ytm. arn set
neu
Set<strtng
set > Cose3'r
phno); not ('ph S-opln kjbrea
Cname)) get <hn Phno
&netC)}
name"
; ("entes nome
So-p Coel
hnput(ome
no); iph k;
brea
next);longt phng-[c.
phno"); enten -outpsnt
lnc Syutero
SConet( name
=
")nane (enter otpsitl tem 1-eade
Cchoice) Switch
))
Systermoutapüntn("erter
choic)e SConeytnt choice= int
Et"); putprintln Systern-
kayset"9Stem-outpintent'
dlal eplay 4.
upolnn.
key")) from vale tetrieve &sten-o
pai")n keyalue phoneSpkenoutpsüntlnt
erten l-
CStermin) 7 Cannen (rue)i
neuo uohile
=Stsc
onnen
phno Lorg
C); lonqStiing, tauhtap< neo
Hasapesthing,
Lorg
=hn
CI) ags Csting in void stotie publie
tashapDerno cln
.ttlbttasbta
ble javatrnpont,
*ulil ipoxt
a
Hahma
32040
2200033040
Rinked list
clas lLTerno
publle static votd roln (siing ogs t3)
Linkedlist <string> u- neo LinkodList cgAring? );
liadd l'aica")}
li add'canado");
l. add('china)s
Sytem.outpoüntla;
Scanner sc neoSanne (syten.in);
String elenert ;
fnt position , choice =0;
ohile choice )
S"oplaC l- add elernent)s
J.opaC nemove an element ");
S-oplnt 3- change an elemet ");
So-psn 4. exit")3
S"opnlenter w choiee");
choice SC next Lntl)
&uoitch Cchote)
Coes: Siopln( ente an element ");
alemet senert())
S-opluleulen positio))
position sc nextSnt ()}
ladd lpositlon , element )?
break;
postlon= nerte)
l.nemave (posttton\5
kaeak.
22000330+0