1- Amend the MyShape class hierarchy in Assignment 2 as follows:
MyArc is_a MyShape;
Class MyArc inherits class MyShape. The MyArc object is a segment of the boundary of a MyOval object, defined by the endpoints (x1, y1) and (x2, y2), or their corresponding angles, on the MyOval boundary. The MyArc object may be filled with any color of MyColor enum reference type. The class includes appropriate class constructors and methods, including methods that perform the following operations:
- toString returns a string representation of a MyArc object;
- draw draws a MyArc
- Implement a Java class MyPieChart that displays a circular pie chart of the probabilities of the n most frequent occurrences of an event to be specified in part 5 of the Assignment. The probability of event is given by:
In the pie chart:
- Each event is represented by a slice of the pie chart. The area of the slice is proportional to the probability of the corresponding event:
- Each slice has a different color of your choice of type enum MyColor; Each slice has a legend showing the corresponding event and its probability; iv. The slices are displayed in order of decreasing probability;
- The last slice represents All Other Events and their cumulative probability. As an example, in the graph below where the event is the occurrence of a letter in a text: n = 3, and the probability of All Other Events is one minus the sum of the probabilities of events e, s, and i;
- The MyPieChart class utilizes a class Slice, and includes appropriate constructors and a method draw that draws the pie chart. The drawing canvas may include appropriate GUI components to input the number of events, n (variable), and display the pie chart together with the events and their corresponding probabilities.
- Class Slice includes appropriate constructors and methods, including methods that perform the following operations:
- toString returns a string representation of a Slice object;
- draw draws a Slice
- Implement a Java class HistogramAlphaBet that calculates the n most frequent alphabet characters in Alice in Wonderland (file Alice in Wonderland.txt) and their probabilities. The HistogramAlphaBet class utilizes a Map collection for statistical calculations and the drawing canvas above to draw a pie chart of the probabilities. It also include the MyPieChart class as an inner class.
- You may only use JavaFX graphics and your own classes and methods for the operations included. Further,
- The code is applicable to canvases of variable height and width;
- The size of the pie chart is proportional to the smallest dimension of the canvas;
Reviews
There are no reviews yet.