Arvutiteaduse instituut
  1. Kursused
  2. 2017/18 kevad
  3. Objektorienteeritud programmeerimine (Narva Kolledž) (P2NC.01.083)
EN
Logi sisse

Objektorienteeritud programmeerimine (Narva Kolledž) 2017/18 kevad

  • 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 
  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused