Institute of Computer Science
  1. Courses
  2. 2017/18 spring
  3. Object-Oriented Programming (Narva College) (P2NC.01.083)
ET
Log in

Object-Oriented Programming (Narva College) 2017/18 spring

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

Tasks (to be submitted by Sun 1.04 23:55) 2 points

Task 1. Flag

Draw a flag of any country using Canvas class. The flag must have at least three colors or a complex shape.

Hint:

  • check the flags here;
  • some shapes and pieces of code can be found here.

Task 2.

Create a program which displays a device, a schema, a masterpiece or anything else. Some examples: a bus timetable panel, a panel of a sports competition, a crossroad, a masterpiece reproduction in the style of abstractionism ...

Some mystery elements can be added using an animation (e.g. due to a programming mistake, the panel flies in the air).

  • The scene graph should have at least four levels.
  • The layout should be regulated by an instance of any Pane subclasses.
  • Any animation should be present.
  • Add at least one effect.

To come up with an idea is not an easy task, but let your fantasy fly. The society needs creative people!

Task 3.

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 the values from the file. The bars whose value is larger than 50 should be filled in with red; the rest bars should be in blue. The value of each bar should be added under the bar.

An example of the output:

Task 4.

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

Session 7 
  • 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