Arvutiteaduse instituut
  1. Kursused
  2. 2018/19 kevad
  3. Objektorienteeritud programmeerimine (Narva Kolledž) (LTAT.NR.003)
EN
Logi sisse

Objektorienteeritud programmeerimine (Narva Kolledž) 2018/19 kevad

  • 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

  • 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