Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javafx.beans.binding.Bindings;
import javafx.beans.binding.NumberBinding;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;

public class Main {
    public static void main(String[] args) {
        IntegerProperty x1 = new SimpleIntegerProperty(0);
        IntegerProperty y1 = new SimpleIntegerProperty(0);

        final NumberBinding x1y2 = Bindings.multiply(x1, y1);

        final NumberBinding sum1 = Bindings.add(x1y2, 2);
        final NumberBinding diff1 = Bindings.subtract(sum1, 1);
        final NumberBinding determinant = Bindings.subtract(diff1, 2);
        final NumberBinding area = Bindings.divide(determinant, 2.0D);

        x1.set(0);
        y1.set(0);

        printResult(x1, y1, area);

        x1.set(1);
        y1.set(0);

        printResult(x1, y1, area);
    }

    private static void printResult(IntegerProperty x1, IntegerProperty y1, NumberBinding area) {
        System.out.println(x1.get());
        System.out.println(y1.get());
        System.out.println(area.getValue());
    }
}