Programming Languages: Java Assignment #4 Due April 6, Monday 11.59PM 1) Create a class TicTacToe that will enable you to write a complete program to play the game of Tic-Tac-Toe. The class contains a private 3-by-3 two-dimensional array of integers. The constructor should initialize the empty board to all zeros. Allow two human players. Wherever the first player moves, place a 1 in the specified square, and place a 2 wherever the second player moves. Each move must be to an empty square. After each move determine whether the game has been won and whether it is a draw. If you feel ambitious, modify your program so that the computer makes the moves for one of the players. Also, allow the player to specify whether he or she wants to go first or second. (Second Column) 2) Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the superclass of the hierarchy. Make the hierarchy as deep (i.e., as many levels) as possible. Specify the instance variables and methods for each class. The private instance variables of Quadrilateral should be the x-y coordinate pairs for the four endpoints of the Quadrilateral. Write a program that instantiates objects of your classes and outputs each object’s area (except Quadrilateral). Example Output Coordinates of Quadrilateral are: ( 1.1, 1.2 ), ( 6.6, 2.8 ), ( 6.2, 9.9 ), ( 2.2, 7.4 ) Coordinates of Trapezoid are: ( 0.0, 0.0 ), ( 10.0, 0.0 ), ( 8.0, 5.0 ), ( 3.3, 5.0 ) Height is: 5.0 Area is: 36.75 Coordinates of Parallelogram are: ( 5.0, 5.0 ), ( 11.0, 5.0 ), ( 12.0, 20.0 ), ( 6.0, 20.0 ) Width is: 6.0 Height is: 15.0 Area is: 90.0 Coordinates of Rectangle are: ( 17.0, 14.0 ), ( 30.0, 14.0 ), ( 30.0, 28.0 ), ( 17.0, 28.0 ) Width is: 13.0 Height is: 14.0 Area is: 182.0 Coordinates of Square are: ( 4.0, 0.0 ), ( 8.0, 0.0 ), ( 8.0, 4.0 ), ( 4.0, 4.0 ) Side is: 4.0 Area is: 16.0 3) Create a class called Rational for performing arithmetic with fractions. Write a program to test your class. Use integer variables to represent the private instance variables of the class—the numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should store the fraction in reduced form—the fraction 2/4 is equivalent to 1/2 and would be stored in the object as 1 in the numerator and 2 in the denominator. Provide a no-argument constructor with default values in case no initializers are provided. Provide public methods that perform each of the following operations: a) Add two Rational numbers: The result of the addition should be stored in reduced form. b) Subtract two Rational numbers: The result of the subtraction should be stored in reduced form. c) Multiply two Rational numbers: The result of the multiplication should be stored in reduced form. d) Divide two Rational numbers: The result of the division should be stored in reduced form. e) Print Rational numbers in the form a/b, where a is the numerator and b is the denominator. f) Print Rational numbers in floating-point format. (Consider providing formatting capabilities that enable the user of the class to specify the number of digits of precision to the right of the decimal point.) Example Output Enter numerator 1: 12 Enter denominator 1: 3 Enter numerator 2: 34 Enter denominator 2: 5 Enter precision: 5 a + b = 54/5 = 10.80000 a - b = -14/5 = -2.80000 a * b = 136/5 = 27.20000 a / b = 10/17 = 0.58823