This performs a code walk-through. The skeleton files you can find for the mini project assignment in Module 8. We'll start by opening up the project, Clicking on the particular files and choosing that in Android Studio. That will go ahead and open up the project, then go take a look at the project. Click down to find the files, you're down here. And we'll start by taking a look at the skeletons that you have to fill in to perform your work. We'll start first by looking at the logic interface. The logic interface is a Java interface that defines the API for processing user calculations. As you can see here, it has one method called process that takes the first argument and the second argument passed in from the user interface, which we'll examine later. As well as the operation that's been selected by the user. And it goes ahead and performs the operation on those particular arguments. So let's go take a look at the logic file. You can see the logic class implements the logic interface. Which means you have to come along and implement this process method. That's where your code will go. You can also see that we keep a reference to the activity output here which is used to interact with the activity from within this code. And then we also have constructor, that takes the activity output reference and stores it in this field that's part of the logic class. As usual, we do this in order to be able to decouple the Java portion of the code from the Android portion. So you can focus your solution purely on the Java portion. Let's now go ahead and take a look at the various files as we mentioned in the earlier video. These are all empty files, you can see add which is a class. divide which is a class, multiply which is a class, and subtract which is a class. And your job as part of this assignment is to figure out how to implement each of these different classes, and then connect them together with the Logic class. So when process is called back by the user interface, you'll go ahead and do the appropriate computations in order to perform the operation to add, divide, multiply or subtract. That's basically what you have to do, so your job is to figure out the appropriate design, figure out the appropriate implementation. Using the various Java features that we've been talking about throughout this mooc. Things like interfaces and classes and inheritance and polymorphism and so on, in order to be able to implement this particular calculator logic. For completeness, we'll also walk you through the user interface. Keep in mind this is not what you actually have to do, you don't actually have to write this code. We provide it to you. But it might be fun to see how it works. We'll go over here and take a look at the main activity. As you can see here, this activity provides the user interface that prompts the user for two integer values, as well as for the operation to perform on these values as shown in the earlier video. Main activity extends activity, and implements activity interface. We'll come and look at activity interface in just a second. Let's go ahead and take a look at some of the fields that are provided in the main activity class. We have something called a spinner, which is a drop down selector, that you can use to choose what operation to use. There's also a button that you can Press when you want to perform the computation. After you've entered the values, you can enter value one and value two which are edit text and that means you can add things to them. And then there's going to be a result that's also stored in an edit text, that stores the results of the computation. That's where the output is actually stored. We also have a reference to the logic object. That, of course, is what you'll be implementing over here, with the logic class that we looked at before. Then at you have to go and fill it. It is also something that it's called an array adaptor. And this is used to adopt and array of characters or characters sequence to make it usable by the map spinner. And this we'll see later on when the program actually runs. Now let's get into a little bit of Android callback methods, these are called lifecycle hook methods. We'll be discussing a lot more about these in the second MOOC in the specialization where we talk about activities in more detail. One of the things that the Android environment does for you, the Android platform does for you, is it has certain hook methods that are called back automatically by the Android platform, by the framework portion of the Android platform. In order to initialize Your activity object. Activities are the ways that you interact with the user. It provide user facing operations. In this case, it's the guey that's used by that calculator to get the input in the operation and then present the output. What we do here is we do a call up to the super class, just always done in android code. We'll talk about that on the next move. You don't have to worry about that here. We call a method to initialize the various views and other fields that are part of the activity and then the final thing we do is we go ahead and create a new logic object passing in this activity and this is actually this which is the object That implements the activity, and that is actually going to be used to give the activity interface to the logic object that we defined over here, so if you look over here you can see that we're passing in something called activity interface, and we'll come back and talk about what that means in a second. This is going to get stored in a field called m logic, so that's now available to interact with the code that you write. Here's the initialized UI method. This again is a lot of detail that we'll talk about more in the next mook so don't worry about understanding it, I'm just going through it now for completeness. We set the layout which dictates how the user will see the user interface with the calculate button and the two edit texts fields to get the input and the other text field to present the output. Down here, we then go ahead and get a bunch of references to the various view objects. These are things that are part of the user interface widgets, or the user interface interactors, components. The button, the edit text fields. The thing called the math spinner, which allows you to be able to select a drop down result, and, the result object. Then we go ahead and create an adapter. Which is going to be used to allow us to visualize the spinner. And the last thing we do is we go ahead and we add, we make the default selection for the math spinner to be add. So if you don't do anything to the contrary, you'll end up adding the two inputs that are given by the user. Naturally, if you want to change that you can go ahead and click on the spinner and it'll select The other operations to perform. When a user actually presses a button, that goes ahead and is automatically dispatched by the Android framework to the button pressed method right here, and that will go ahead and get the operation number. We'll take a look at how that works in a second. Once we got the operation number we get the first value and the second value and it's specified by the user in the user interface. And here then is the hook that connects with the code that you write. We end up calling the process callback method or hook method on the logic reference with ARC one, ARC two in the operation. And that vectors you over here where this code is going to be run. The code that you write there. If you go down a little bit and take a look at some of these helper methods. You see get value one and get value two. Essentially take the string that was given through the user input and converts that into an integer for value one and for value two. So those are returned as ints. And then down here we also have a way of being able to select the appropriate choice from the math spinner to get the appropriate operation as an operation number. So I think add is one, subtract is two, multiply is three, divide is four, and so on, and so forth. Here, then, is the way in which we print the result to the user output. This is something of course, that you'll end up needing to call from within your logic/process method. When you're all done, you'll go ahead and call back and you'll print the result, which just goes ahead and sets the text. For the result to be the text string, the string that's passed in here. So that's basically how the activity works. Let's now go take a quick look at the activity interface. You take a look up here you'll see that the main activity implements activity interface. Here's activity interface. As you can see, the activity interface simply provides some ways of getting at various values that the user provided. In this particular case, the only one that really matters is the print method, we provide the other ones here just if necessary, but they're actually passed in as you can see as the value of argument one, argument two and operations, so that's actually Not strictly necessary here, we only really need to provide the print method. And we use this activity interface in order to be able to have a very loose coupling between the activity, the math activity that we defined here, which is all Android code. And then the code that's over here in the so called logic folder, and this is the code that by in large is just plain old Java code and so you don't have to really know much, if anything, about android in order to be able to carry out this computation whereas that allows us to write the android activity over here. We're doing that in this course for a couple of reasons. The main reason is that we don't have to teach you everything you need to know about android at this point. And then later, when we get to the next course, we'll teach you more about how these things work. And we're also doing this because it makes it easier to mock up various test applications to test the logic here without having to drag in all the android operations, and the android platform, and the android framework. And that of course was used earlier in order to make it easier to write unit tests we could use with our auto graders. Here's a bit more of this again we'll cover again at the next class. These are some of the resources that are provided as part of the android studio environment to dictate the way in which information is laid out on the screen. Here is activity_main.XML If you go over here to main activity you can see that there's a reference to activity main here We do this set content view call that basically says that this will be main activity for rather the main layout for the set activity. So if we go take look at this it's going to be XML file and there we go it's showing what the view looks like so you can see we have value one, value two, you've got spinner here which gives you the different items You have the calculate button and then you've got the output edit text for the result. So those are some of the things that you get here. Here's what this actually looks like in the XML format. And I'm not going to go through this in gory detail right now. This is something that we'll cover again in the next mu. But basically what you can see here is we Indicate that this particular text view is going to give you a prompt to enter the value one text, and then we're going to have the input for this. That's the edit text and it's given a name, and we're going to use those names in the main program. If you take a look over here, you can see we can go look those things up by their name. Come down here, we see another prompt which is going to be for editing the value of, to edit text. We have a calculate button and we can see that this particular XML descriptor says when somebody clicks on this button, call back to the button press method. And if you take a look over here, here is button pressed. It's right there. There's the button pressed method. So what this is doing is it's basically connecting this resource file, is connecting the button that's clicked on the user interface with this method that's defined In the Android activity. And we'll talk again later about other ways of doing that, that's just one way of doing it. And next week we'll cover that in more detail. Here's how we define the spinner and here's how we define the results that'll be printed out. So again, you don't have to know about all of this stuff in order to do the assignment. I'm just walking you through it because it's kind of fun. To get a preview of what's going to come along later in the course, but the main thing to remember for right now is that you need to start focusing on the Logic file and filling out how you do the process method, and then implementing the Add, Divide, Multiply, and Subtract files. And we intentionally made this assignment quite open-ended to give you Maximal ability to be creative, and that's why we're going to be doing this using peer evaluation as opposed to auto grading, because people will do things in different ways, and we didn't want to be restrictive in the in which we evaluated, we wanted to let you guys be as creative as you'd like. So that's the walk through of the skeletons, hope that that is helpful to you, and of course as always, please feel free to Contact us on the discussion forums if you have any questions what so ever.