‫Let's find x2.
‫It's similar to x one, but the plus sign is replaced by minus sign.
‫Minus B minus.
‫Radical discriminant over two a and here I need to display the results in the text view.
‫I need to display the root x one and x two.
‫For that I'll use main binding or binding here object that we created before.
‫Here.
‫I'll use it to set the text view to the solution.
‫This is the case if the discriminant greater than zero two real and distinct roots.
‫Else if the discriminant less than zero.
‫I need to display a message and the text displaying no real solutions for that binding dot text view
‫Dot Set Text.
‫No real solutions.
‫No real roots.
‫Complex roots.
‫Else If the case it is equal to zero, we have one real solution or double root.
‫So for that I need to calculate x one equal minus b over two times a.
‫This is the case of double root.
‫This is how we find the double and only one root x one equal minus P over two a.
‫This is the case if the discriminant equals to zero.
‫And of course I need to use binding dot text view dot set text.
‫We have this double root x equals to x one.
‫Now we need to link this data class with our layout here.
‫I need to create a data variable.
‫Let's start with data and here I need to use the variable, the name, I name it as my equation.
‫The second attribute is the type I need to specify it.
‫Campmaster Coding dot quadratic equation solver.
‫My equation.
‫This is the type of the class that acts as the data source.
‫Then I need to specify here in the edit text and I need to specify the text.
‫And since I'm using the two way binding I need to use at equals sign and these two braces my equation
‫dot a I'm getting a from the first edit text.
‫I need to get B from the second edit text and set it to the b variable here in the My equation class.
‫And the last thing to do is my equation.
‫Dot C Let's go to the button a button here.
‫We need to use the click handlers.
‫As I told you in the previous videos, I need to use my onClick attribute, add two braces and I'll
‫specify my equation variable dot or two colons dot solve equation.
‫This is the method that I need to execute from the my equation class.
‫So solve equation took into parameter.
‫If you don't miss to pass a view variable in order to link this method with this button.
‫Now let's move to the main activity and create an instance of the main binding object activity.
‫Main binding main binding and I'll initialize it here.
‫Main binding equal to data binding util dot set content view to this as an activity parameter.
‫And the second one is r dot layout dot activity main goes.
‫I need to link this activity, underscore main layout with our main binding object.
‫I'll create an equation object equation equal to new my equation and I need to pass main binding object
‫to it to link the main binding with the data class which is my equation.
‫I'll use main binding dot.
‫Set my equation to this equation.
‫Save the project clean project.
‫If you have any errors in the data binding library, please always use rebuild the project before running
‫the application.
‫Let's run.
‫Let's test our application.
‫I'll use two x squared minus five x plus three, five and here plus three A, B and C click solve.
‫We have the first solution or the first root is six, and the second solution is four.
‫But this is not the solution.
‫I think there is an error here in the division.
‫I need to add these parentheses in order to make the division so always enclose the equation with parentheses
‫and when you divide you need to add for the numerator, the parentheses and the denominator with parentheses.
‫Run the application again two minus five and three solve.
‫And here we go.
‫This is the correct solution.
‫The first root is 1.5 and the second root is one.
‫So congratulations, guys.
‫We succeeded in creating this amazing application that solves the quadratic.
‫Questions where the help of the data binding library.