Sunday, 29 November 2015

Learning Java Collections and Interfaces with Frogs, Sheep and Owls

A couple of days ago a funny drawing from Twitter caught my eye. I thought it would make a good exercise for kids learning Java. Here it is:
I quickly drafted a model and saved it at GitHub:

I had thought the exercise would be easy, but when I started to sketch a program to solve the puzzle I realized that was not the case. Knowledge of Java collections and interfaces seemed to be neccessary. Moreover, teaching the computer how to determine X, knowing that X*X*X = 27, raised unexpected issues:
What do you think? Are these quizzes helpful in teaching kids programming?

I am looking forward to your opinions in the comments below or at Moodle Cloud.

Sunday, 11 October 2015

Five Things To Remember About The Map Interface


  1. Maps are collections of key-value pairs.
  2. The keys are unique.
  3. Several keys can refer the same value.
  4. TreeMap implements SortedMap.
  5. The Map interface does not extend java.util.Collection.



Look inside >
75
Quiz Yourself

Saturday, 15 August 2015

Saturday, 18 April 2015

How to learn from scratch

Motto:

I think that writing great computer programs is like writing wonderful poetry. Nobody can teach us the creative act. But we all have to learn how to write, in order to be able to handle correspondence related to our taxes, for instance. And to be able to read great poetry.

Similarly, we should all learn how to program computers, in order to be able to program our refrigerator, for instance. And to be able to read and appreciate wonderful computer programs (and programmers).

Saturday, 14 February 2015

JavaFX Scene With Shapes

If a scene has only shapes, requestFocus() must be used explicitly before being able to process keyboard events.

I tried it myself! See below.


SceneWithShapes.java




FXMLDocument.FXML



FXMLDocumentController.java


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package scenewithshapes;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import static javafx.scene.input.KeyCode.A;
import javafx.scene.input.KeyEvent;

/**
 *
 * @author Cristina
 */
public class FXMLDocumentController implements Initializable {
       
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }  
    
    public void keyHandler(KeyEvent event){
    System.out.println("A Key was pressed");
  }
    
}




Bibliography