Institute of Computer Science
  1. Courses
  2. 2018/19 spring
  3. Object-Oriented Programming (Narva College) (LTAT.NR.003)
ET
Log in

Object-Oriented Programming (Narva College) 2018/19 spring

  • Home
  • Materials
  • Java Glossary
  • Source Example
  • Cheat sheet (S1-S6)
  • Grading
  • Links

slides_s8.pdf

Task 1.

Create a .txt file which contains some digits (each digit on a separate line). Write a program which reads in the data from the file and draws a bar chart according to the values from the file. The bar whose value is larger than 50 should be red; the rest should be blue. The value of each bar should be added under the bar.

An example of the output:

Task 2.

Write a program which draws an interface of a calculator (the calculator does not have to work). Use at least two different panes (class Region or its subclasses). There should be space between the buttons. The result of a calculation should be on the white background and in the right corner. The color of the text on the buttons should be either red or blue. The size of the window should be fixed.

An example of the interface:

Task 3.

Write a program which demonstrates all the colors of Color class. Some examples of the output:

or

or

or ...

The following method returns a list of all the colors:

 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import javafx.scene.paint.Color;
 ...
	static ArrayList<Color> allColors() throws Exception {
	    ArrayList<Color> colors = new ArrayList<Color>();
	    Class<?> myClass = Class.forName("javafx.scene.paint.Color");
	    if (myClass != null) {
	        Field[] field = myClass.getFields();
	        for (int i = 0; i < field.length; i++) {
	            Field f = field[i];                
	            Object obj = f.get(null);
	            if(obj instanceof Color){
	            	colors.add((Color) obj);
	            }

	        }
	    }
	    return colors;
	}

In the second example, the following effect is used - RadialGradient

  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment