1 00:00:00,195 --> 00:00:02,490 ‫Instructor: Hi! Within this lecture, 2 00:00:02,490 --> 00:00:06,210 ‫I'm going to take you over our game app code. 3 00:00:06,210 --> 00:00:08,670 ‫So if you are new to Java and under a development 4 00:00:08,670 --> 00:00:10,440 ‫this lecture may be good for you 5 00:00:10,440 --> 00:00:12,600 ‫to understand what's going on, 6 00:00:12,600 --> 00:00:14,675 ‫on the background of these kind of games. 7 00:00:14,675 --> 00:00:17,130 ‫And if you are already experienced, 8 00:00:17,130 --> 00:00:20,850 ‫I suggest you skip this lecture and don't look at the code 9 00:00:20,850 --> 00:00:25,440 ‫so that it will be much more realistic for you 10 00:00:25,440 --> 00:00:27,840 ‫to reverse engineer it first 11 00:00:27,840 --> 00:00:30,525 ‫before seeing the codes themselves. 12 00:00:30,525 --> 00:00:31,710 ‫Okay? 13 00:00:31,710 --> 00:00:34,710 ‫So here you go, here is our game manifest, 14 00:00:34,710 --> 00:00:37,200 ‫our main manifest, and as you can see, 15 00:00:37,200 --> 00:00:39,270 ‫there is not much to see over there. 16 00:00:39,270 --> 00:00:42,210 ‫Let's just jump into our codes. 17 00:00:42,210 --> 00:00:46,470 ‫So we see the game activity and in the manifest 18 00:00:46,470 --> 00:00:48,900 ‫it was listed as the launcher activity, 19 00:00:48,900 --> 00:00:51,300 ‫which is the first activity. 20 00:00:51,300 --> 00:00:56,300 ‫In fact, we only have this activity in our game. Okay? 21 00:00:56,689 --> 00:00:59,098 ‫And as you can see, there are some texts, 22 00:00:59,098 --> 00:01:02,580 ‫like input text, core text, category text, 23 00:01:02,580 --> 00:01:05,730 ‫so let me go to our XML. 24 00:01:05,730 --> 00:01:07,890 ‫So let me make this a little bit smaller 25 00:01:07,890 --> 00:01:09,990 ‫so that we can have a space. 26 00:01:09,990 --> 00:01:13,890 ‫If you come over here, you will see there is an input text, 27 00:01:13,890 --> 00:01:17,490 ‫there are two buttons, one for category, 28 00:01:17,490 --> 00:01:21,090 ‫and one for sending the guess. Okay? 29 00:01:21,090 --> 00:01:24,030 ‫And as you can see, there are some unclick methods 30 00:01:24,030 --> 00:01:26,739 ‫assigned to those buttons like, sendButtonClicked. 31 00:01:26,739 --> 00:01:29,860 ‫And for this changeCategoryClicked, 32 00:01:29,860 --> 00:01:34,140 ‫we will see the related methods in the JAVA section. 33 00:01:34,140 --> 00:01:36,330 ‫So over here we have the score text, 34 00:01:36,330 --> 00:01:38,419 ‫where we display the score itself. 35 00:01:38,419 --> 00:01:42,518 ‫So if you come over here you will see all the defined texts, 36 00:01:42,518 --> 00:01:46,890 ‫and also you will see the related methods, as well. 37 00:01:46,890 --> 00:01:50,192 ‫So after defining the texts, 38 00:01:50,192 --> 00:01:53,340 ‫I am creating something called score, 39 00:01:53,340 --> 00:01:56,280 ‫and actually I defined it as a global variable, 40 00:01:56,280 --> 00:01:58,950 ‫and I'm initializing it to be zero, 41 00:01:58,950 --> 00:02:00,600 ‫when on create is called. 42 00:02:00,600 --> 00:02:04,830 ‫So score starts at zero, as expected. Okay? 43 00:02:04,830 --> 00:02:08,760 ‫And I also have a variable called categoryCounter, 44 00:02:08,760 --> 00:02:12,660 ‫which is already zero at this moment. 45 00:02:12,660 --> 00:02:17,040 ‫And then we're creating come models, called WordModel, 46 00:02:17,040 --> 00:02:21,120 ‫and here you can see the WordModel on JAVA itself. 47 00:02:21,120 --> 00:02:24,120 ‫So if you come over here, you will see that it's a class, 48 00:02:24,120 --> 00:02:29,100 ‫and it already has some attributes and constructors. 49 00:02:29,100 --> 00:02:31,260 ‫As you can see we have this category name, 50 00:02:31,260 --> 00:02:32,130 ‫which is a string, 51 00:02:32,130 --> 00:02:37,130 ‫and gameWords, this is an array list of strings. Okay? 52 00:02:38,130 --> 00:02:42,120 ‫So we're going to have a look at this gameWords 53 00:02:42,120 --> 00:02:44,490 ‫later on in here. 54 00:02:44,490 --> 00:02:49,020 ‫So if you come over here, there's a ModelPopulator class, 55 00:02:49,020 --> 00:02:51,240 ‫which actually populates the model, 56 00:02:51,240 --> 00:02:55,410 ‫like, creates the array list of keywords 57 00:02:55,410 --> 00:02:58,860 ‫like banana, apple, watermelon, melon, grapes, 58 00:02:58,860 --> 00:03:01,440 ‫so you can actually see the keywords 59 00:03:01,440 --> 00:03:04,170 ‫in this ModelPopulator over here. 60 00:03:04,170 --> 00:03:06,600 ‫Of course, we are doing this only for practice. 61 00:03:06,600 --> 00:03:11,600 ‫In real life, you won't get these key words easily. 62 00:03:12,180 --> 00:03:16,205 ‫I'm just trying to make you familiarize with the codes 63 00:03:16,205 --> 00:03:18,240 ‫of this application, 64 00:03:18,240 --> 00:03:21,720 ‫then we will go onto the reverse engineering, okay? 65 00:03:21,720 --> 00:03:22,950 ‫So if you come over... 66 00:03:22,950 --> 00:03:24,697 ‫Come back to gameActivity, 67 00:03:24,697 --> 00:03:27,167 ‫you can see we created three models 68 00:03:27,167 --> 00:03:30,300 ‫for fruitModel, bandModel, and dogModel. 69 00:03:30,300 --> 00:03:33,150 ‫So we have three categories, as you can see, 70 00:03:33,150 --> 00:03:38,150 ‫one for fruit, and bands, and one for dogs, as well. 71 00:03:38,220 --> 00:03:41,280 ‫And we add all these models 72 00:03:41,280 --> 00:03:44,460 ‫to our array list containing categories, 73 00:03:44,460 --> 00:03:47,241 ‫like containing actually, wordModels. 74 00:03:47,241 --> 00:03:50,430 ‫So the category's array list, if you come over here, 75 00:03:50,430 --> 00:03:53,103 ‫you will see that it contains wordModels. 76 00:03:54,510 --> 00:03:57,609 ‫So wordModel objects that we have just created 77 00:03:57,609 --> 00:04:00,570 ‫go into that category array 78 00:04:00,570 --> 00:04:04,080 ‫and we call something called categoryRefresher. 79 00:04:04,080 --> 00:04:06,600 ‫If you come over here, to categoryRefresher, 80 00:04:06,600 --> 00:04:09,360 ‫you can see there is a current category, 81 00:04:09,360 --> 00:04:12,810 ‫which was set to be zero initially, 82 00:04:12,810 --> 00:04:17,040 ‫and it defines the category text. 83 00:04:17,040 --> 00:04:18,210 ‫We haven't talked about this, 84 00:04:18,210 --> 00:04:20,610 ‫Here is our category text right now, 85 00:04:20,610 --> 00:04:23,490 ‫and this is how we set the category text. 86 00:04:23,490 --> 00:04:26,299 ‫We get it from the array list 87 00:04:26,299 --> 00:04:29,910 ‫and we get the category name afterwards, 88 00:04:29,910 --> 00:04:34,910 ‫and we use this check key word, check guess, 89 00:04:35,130 --> 00:04:38,550 ‫maybe if you want to call it that way. 90 00:04:38,550 --> 00:04:42,420 ‫When we click on sendButton, 91 00:04:42,420 --> 00:04:43,650 ‫and as you can see, 92 00:04:43,650 --> 00:04:48,540 ‫checkWord returns 1 if the current category 93 00:04:48,540 --> 00:04:51,589 ‫contains user input, okay? 94 00:04:51,589 --> 00:04:56,589 ‫If it contains this user input then we return 1 in checkWord 95 00:04:56,817 --> 00:05:00,540 ‫and if it doesn't contain, we return zero. 96 00:05:00,540 --> 00:05:04,080 ‫And it takes that returning integer 97 00:05:04,080 --> 00:05:08,229 ‫from that checkWord method and adds it to score 98 00:05:08,229 --> 00:05:13,229 ‫and then it sets the score with the current score number. 99 00:05:13,350 --> 00:05:16,006 ‫So this is a very simple game, of course, 100 00:05:16,006 --> 00:05:20,370 ‫there can be a lot of improvements regarding to this game 101 00:05:20,370 --> 00:05:23,550 ‫but it works right now and it is suitable for us 102 00:05:23,550 --> 00:05:26,883 ‫to test our reverse engineering skills. 103 00:05:27,990 --> 00:05:32,227 ‫And we have changeCategory clicked over here finally, 104 00:05:32,227 --> 00:05:36,930 ‫where we increase categoryCounter by 1 105 00:05:36,930 --> 00:05:40,890 ‫every time I hit the changeCategory button 106 00:05:40,890 --> 00:05:45,890 ‫and it increases by 1 and we get the current number 107 00:05:46,890 --> 00:05:49,380 ‫with CategoryCounter integer. 108 00:05:49,380 --> 00:05:52,650 ‫So we have three JAVA files over here 109 00:05:52,650 --> 00:05:55,620 ‫and of course, I made the obfuscation enabled, 110 00:05:55,620 --> 00:05:58,230 ‫I made the proguard usage enabled. 111 00:05:58,230 --> 00:06:01,937 ‫So we won't be able to see those codes clearly 112 00:06:03,270 --> 00:06:06,000 ‫or here we will see them obfuscated, 113 00:06:06,000 --> 00:06:09,289 ‫we will see them encoded and we are going to 114 00:06:09,289 --> 00:06:13,590 ‫try and understand what's going on in this app 115 00:06:13,590 --> 00:06:15,300 ‫by looking at those codes. 116 00:06:15,300 --> 00:06:16,803 ‫See you in next lecture.