Class : Functions_GUI - VadimKachevski/OOP_Ex1 GitHub Wiki

The Class Functions_GUI is implementing functions interface which extends Collection.


The Class holds a Collection of functions. In addition to supplying basic Collection functions it also Draws in a JFrame GUI the funcions from the collection,reads functions from file and creating a collections from them, save the collection into a readable txt file.

Methods for Functions_GUI:

initFromFile(String file) - with a given String path to a file , it will read the file in the following format: each line will start reading the fucntion when it finds a f(x): f(x)= "some sort of a fucntion" or if f(x) is not present it will read the whole line therfor it should have a valid form of a function. The method initFromFile will read each line and add it to the collection of function. the function should be a valid form of a function.

saveToFile(String file) - with a given String path to a file, it will create or override a file given and write into the file each function in a separate line in the format of: f(x) = "some sort of a function"

drawFunctions(int width, int height, Range rx, Range ry, int resolution)- with given parameters of Width,height, range for x, range for Y and resolution, it will create a new JFrame with the given parameters and draw X-axis in the range, Y-axis in the range and the squares panel than it will draw all the functions in the collection with a random generated color, it will also write into console the Color used and the function. Another way to receive the parameters is via a JSON file.

drawFunctions(String json_file)-with a given JSON file path it will read the parameters of width,height,Resolution,Range_x (which is an 1x2 array),Range_y (which is a 1x2 array). if any of the of the following doesn't exist in the JSON it will use the default following parameters for the missing parameter. Width=1000 Height=600 Resolution=200 Range_X = {-10,1} Range_Y = {-5,15}

⚠️ **GitHub.com Fallback** ⚠️