Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BR 1 8 Rifl ksh n na we f f n di str kch f wan program. I rili yusful we yu nid f mek

BR18 "Riflkshn na we f fn di strkch f wan program. I rili yusful we yu nid f mek yu kd rili fleksibul. Tu fayl dn de we de insay dis lab:
Di wokman.java
EmployeeQuery.java f di wan dn we de wok
Di Employee.java fayl fiba di wan we wi bin mek na lekch, bt sm pan di fil, getter, n setter we dn de yuz dn chenj. Yu n go chenj dis fayl di tm we yu de du di lab.
Luk di EmployeeQuery.java fayl. Notis se na program we de mek psin we de yuz am aks data frm wan Employee bjkt. Di men we na wan lp we de gt input frm di psin we de yuz am. Di lp de yuz wan Skan f pross di yuz input. Scanner na wan klas f di API we dn kin yuz f pars tks data. Insay dis kes, wi js nid f gt di nks ""wd"" we di yuza tayp insay If di yuza tayp insay getName, getAddress getCity, di program de ansa wit di data n di lp dn. If di psin we de yuz am nta f lf, di program go stp.
Fs notis se if wi want f mek di yuza aks l di psibul getter mtd dn f Employee.java, wi go nid wan bku big if stetmnt. Dn bak, if wi disayd leta f chenj di Employee.java fayl bay we wi ad pul di getter mtd dn, wi go gt f chenj di EmployeeQuery.java fayl.
Bt if wi yuz riflkshn, wi n nid f rayt wan big if stetmnt,n wi n nid f chenj di EmployeeQuery.java fayl vri tm we di Employee.java fayl chenj.
Task 3: Progrm wit Riflkshn
F yuz riflkshn, yu nid f import klas dn frm di java.lang.reflect pakej.
Dn kin yuz riflkshn f chk wetin de insay wan klas sntin. Fgzampul, if yu gt bjkt we na String s = nyu String(), yu kin yuz di stetmnt
Klas cls = s.getKlas ();
,n naw cls na wan vribul we de kip di tin dn we de insay s.
F gt wan we frm s, yu kin yuz
Mtd we = cls.getMtd (mtdNem, paramitaAry);
Di skn paramita na wan list f di kayn paramita dn f di we aw yu want. Dis f bi wan arenjmnt f Klas. F gt wan we we n gt paramita, js pas insay wan mti arenjmnt: nyu Klas[0].
Mtd de kip wan mtd. F kl di we aw dn de du am, yuz
method.invoke(dn, argumntAry).
s na di bjkt we yu de kl di mtd pan, n argumentArray na wan arenjmnt f argumnt f pas to di mtd. Dis f bi wan arenjmnt fbjkt. If yu de kl wan mtd we n gt argumnt, pas wan mti arenjmnt: nyu bjkt[0].
Notis: Yu go gt wnin msej we yu de mek wan arenjmnt f Klas. Dis na biks Klas gt jenrik tayp, bt biks yu n ebul f mek wan arenjmnt wit paramitaiz jenrik, yu f drp di jenrik we yu mek wan arenjmnt we gt tayp Klas. Yu f ignore dis wnin msej.
Wetin yu f du:
As wi bin dn tk p, dn n go tl yu ustm f chenj di wok dn we yu f du. Bifo dat, yu n yu patna f disayd na difrn say dn na di lab udat f bi di drayva n udat f bi di navigat. Ivin if dn n go tl yu f chenj, yu stil nid f fala gud paired-programming practice: na di drayva we de naw nm go ebul fdit di dkyumnt.
F di lab, chenj di kd so dat yu go kl ni getter mtd we di yuza tayp insay n yu print di rizlt f kl da mtd de. Yu f yuz riflkshn so dat di aktual mtd nem n go apia nisay na yu kd. Fgzampul, di psin we de yuz am f ebul f tayp getName, getCity, getAddress, n da tin dn,n di program go ansa wit di rayt data. Di program f stil stp we di psin we de yuz am nta f kmt,n di program f ignore ( print mistek msej) if di yuza nta valyu we nto mtd nem, n kntinyu f go.
Task 4: Wan Sml M Chalenj
If yu dn Task 3, tray f chenj yu kd so dat di psin we de yuz am go ebul f rayt di nem dn bak f di sta mtd dn. If na so i bi, di psin we de yuz am go nid f put di valyu f kip, n dn f kl di rayt sta we f kip di valyu. As hint, yu kin yuz di getMethods we f gt wan arenjmnt f di pblik we dn we de. Dn, yu kin luk p na di arenjmnt di mtd nem we di yuza tayp. Frm di we, yu kin no di nmba n di kayn input paramita dn,n afta dat yu kin rid insay (n pars if nid de) di rayt nmba f di input dn to di we."

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

=+e) What is the marginal distribution of the campus constituents?

Answered: 1 week ago

Question

What aspects would it be impossible to capture?

Answered: 1 week ago

Question

Enhance your words with effective presentation aids

Answered: 1 week ago