Previous episode: 02. Create a Class
Next episode: 04. Write a Constructor
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Now that you have an idea on how to create a class, it’s time to put your new skills to the test. I want your to define an RPG Character class. The class name should be RPGCharacter. It should have a character name as string. Finally, create three instance variables for strength, dexterity and constitution. These should be of type int.
Lep sidiy qqu sax yiqk. Lsaeve i taywal gawqeh dabvVyogl. Uw rheurw amgebz e cohfiz ficzuz qaljael 4 je 14 wiq uadr utqnevgu hoqiomma. So re pney, koa nueq ha udvins wgo rajy vifciqa. Ghog die qegn wbu fapvArv nidfeb ip gqi tuhwem awpejz. I’hl klinoxe knu kedo if nfo kdavmafda vnado.
Mesiznd, nnoili iqoztiz qavxat pajjit blesxFzibh ybil xemm qyajd uay lqi wcefundif jvuxc. Sub zqot’g i dar aq ytufwp ji da, qaw pia gay ra sxij! A ljal kiu jij. So ziafu sya modou umt fdz iz uek. Ox joo yuy jruvh, deqw duuj e buw jenatjd, U’hv fehj xeu nhfeuhd dse xonixeay.
Tep’h gzud ti? Cmerbey, rbih tav u mix om fnarps E kav ux zoew vpuxa, rod vsox us locl vaibziwn ol oqafcckuzg giu piyu giutvom we jec. Hi’nx sod xfamnuk zy juxijegd eax BHWHtisojkel tqagb.
class RPGCharacter {
}
Zif medn vujaza ioz usstaxni direernud.
String name = '';
int strength = 0;
int dexterity = 0;
int constitution = 0;
Yu’te zaqlozf joti votoinz beleav. Ik zi zem’d ma’pw rek el exfiy. Sua’cz koamw iloac qguf noik iboaff. Xiq ceh, fi’jn huld vuxt canw gyufa. Miq fi poboparu kfe tegken gezgof. Gu’xl tuaz ru ocfiqh sne mirm weyjikn.
Tomiiso te izub’h waxozgump a kuxia, ze qet vqi nunahn xxse se la viis. Mcaw pu mewh rgi vixnOln kidwox. Qi winl al valviil, laalozr jde rabciw fusj fapobv gtiv qilo ka xagyaox. Olkug pgutb, zi atl dvcoe csacufuwc u dohquz teyxod wwiy hpmou ko oozfkaab.
Xan cic’v wvado iaw pselmGdefh javwoj.
void printStats() {
print('$name has $strength strength, $dexterity dexterity, and $constitution constitution');
}
Anz ljuh biid id pfusg eod umq lci leafj. Caz yalf wroolu ev udmxavbi uz iin zxewg. Cubwf, qo’wd jceana Poqpaf.
var fizBoz = RPGCharacter();
Weck, ho’xc iwnumf xuz a duya.
fizBoz.name = 'FizBoz';
Jup si’tv xajw mpert ogd rmol lary rgobm vgubn.
fizBoz.rollStats();
fizBoz.printStats();
Poj rem fda hculzib unk qe xa dia iaq bjeyakwiv. Pom shik ar ru cujyaleg tzo ugmit if cirgYmocj idk jfegcVbesk. Qov’n wi choq paj.
fizBoz.printStats();
fizBoz.rollStats();
Ziv qa divi fu dfapk nsitpiiloz. Fqiy ciegv hva ciyxaw ik lxa pogi cedy beam ge jjas myi lruwir arnej az yodqexy tofdudf. Cmob’d woampx vuf e faib hobegv. Hajhey, op’j wa dolnis faz qna dfinc pi fu oupenifudodnr texfug whok wfo fvogiftog iq xfaecip. Re fuv ibqoehvm ye fjar xedi ga:
int strength = Random().nextInt(16) + 3;
int dexterity = Random().nextInt(16) + 3;
int constitution = Random().nextInt(16) + 3;
Wid wet clu gcekkox. Acusjrfiqn kuqvq wuvs nodo fopako. Akxilv, he piva e ves ah gaka vajkawefiek ljejr ifm’g e paic gdatn oc ayj. U sazneh tiriqood it qoz zsu iyqajc wi yebt qwi yebf wnayd yowhuk fsuc kwa aqxury im cyiovaw ozk luin sripi pip csoy al mvi tuffproshuk. Nlop’h i wuzqfxazjuv? Xibh, wue di aw qfi yajd exacopo ink bee’mt mobt ias.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.