Docsity

Programming Assignment 2 - Principles of Programming Languages | CS 181, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
Programming Languages CS 181
Fall of 2001
Programming Assignment #2
Due: Wednesday, December 12, 11:59pm
Design an MS Java++ 6.0 program that interactively displays graphs of several basic functions
depending on the selected parameter 1 โ‰ค N โ‰ค 10. The program window is supposed to consist of a
canvas area that displays the graph f(x) with both axes drawn and scaled. Each of the three types of
functions has to be displayed in different color. The x axis extends from 0 to 5 while the scale of the y
axis depends on the displayed function and is chosen so that the graph essentially fills the whole area
of the canvas (minimizes the white-space).
The window also contains a control area which consists of:
๎˜ A โ€œNewโ€ button that displays the graph of a chosen function for the selected N after first clearing
the canvas area. The New button should be only active if the type of the function and the number
N have been already selected.
๎˜ An โ€œAddโ€ button that adds the graph of the newly selected function to the previous graph(s). This
button should be only active if some other function is already displayed and if the type of the new
function and the number N have been properly selected. It should allow us to choose only a
function of a different type than the one(s) already displayed in the canvas area. Otherwise, an
error message should be issued. In particular, at most three different graphs can be displayed at
the same time.
๎˜ A โ€œClearโ€ button that clears the canvas area and all the control fields.
๎˜ A pushdown list (initially set to <none>) that selects one of the three types of functions:
๎˜ Exponential, i.e., Nx
๎˜ Power, i.e., xN
๎˜ Sinus, i.e., sin(Nx).
๎˜ A text input field (initially blank) through which one can change the parameter N.
๎˜ Two text fields (initially blank) which display the values of x and f(x) whenever a mouse moves
over a point on the canvas area with the x coordinate, where f(x) is the last selected function (if
any).
๎˜ A label area that shows the list of all currently displayed functions with the last chosen function
listed first.
Good Luck!

Partial preview of the text

Download Programming Assignment 2 - Principles of Programming Languages | CS 181 and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

Programming Languages CS 181

Fall of 2001

Programming Assignment # Due: Wednesday, December 12, 11:59pm

Design an MS Java++ 6.0 program that interactively displays graphs of several basic functions depending on the selected parameter 1 โ‰ค N โ‰ค 10. The program window is supposed to consist of a canvas area that displays the graph f(x) with both axes drawn and scaled. Each of the three types of functions has to be displayed in different color. The x axis extends from 0 to 5 while the scale of the y axis depends on the displayed function and is chosen so that the graph essentially fills the whole area of the canvas (minimizes the white-space).

The window also contains a control area which consists of:

 A โ€œNewโ€ button that displays the graph of a chosen function for the selected N after first clearing the canvas area. The New button should be only active if the type of the function and the number N have been already selected.

 An โ€œAddโ€ button that adds the graph of the newly selected function to the previous graph(s). This button should be only active if some other function is already displayed and if the type of the new function and the number N have been properly selected. It should allow us to choose only a function of a different type than the one(s) already displayed in the canvas area. Otherwise, an error message should be issued. In particular, at most three different graphs can be displayed at the same time.

 A โ€œClearโ€ button that clears the canvas area and all the control fields.

 A pushdown list (initially set to ) that selects one of the three types of functions:

 Exponential, i.e., Nx  Power, i.e., xN  Sinus, i.e., sin(Nx).

 A text input field (initially blank) through which one can change the parameter N.

 Two text fields (initially blank) which display the values of x and f(x) whenever a mouse moves over a point on the canvas area with the x coordinate, where f(x) is the last selected function (if any).

 A label area that shows the list of all currently displayed functions with the last chosen function listed first.

Good Luck!