I can write simple Java programs. 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> "abc"
"abc"
> "12"
"12"
> 12
12
> 1 + 2
3
> "1" + "2"
"12"
> '1' + '2'
99
> '1'
'1'
> '1' + 0
49
> '1' + 3
52
> (char) ('1' + 3)
'4'
> (char) ('A' + 3)
'D'


import java.util.Scanner; 

public class Three {
  public static void main(String[] args) {
    Scanner ollie;
    ollie = new Scanner(System.in);
    // System.out.println( ollie ); 
    System.out.print("What's your name: "); 
    String name = ollie.nextLine(); 
    System.out.print( "How old are you, " + name + ": ");
    String age = ollie.nextLine(); 
    int a = Integer.parseInt( age );
    System.out.println( name + ", you will be " + (a + 1) + " next year." ); 
  }
}

Next we develop incrementally Penguin:

import javax.swing.JComponent;
import java.awt.Graphics; 
import java.awt.Color;
import java.awt.Polygon;

public class Penguin extends JComponent {
  int width, height; 
  public Penguin(int width, int height) {
    this.width = width;
    this.height = height; 
  }
  public void paintComponent(Graphics g) {
    // default color is Color.BLACK 
    g.drawOval(  0,   0, 550, 550); // circle in the background (not necessary) [ 0] 
    g.setColor(Color.WHITE); 
    g.fillRect(  0,   0, 500, 500); // background (see marks by circle)         [ 0]   
    g.setColor(Color.BLACK);        // used by body                             [ 1] 
    int left = 5;
    g.fillOval( 80-left,  50, 365, 400); // body                                [ 1] 
    g.setColor(new Color(220, 220, 220)); 
    g.fillOval(120-left, 190, 290, 250); // larger belly                        [ 2] 
    g.setColor(Color.WHITE); 
    g.fillOval(155-left, 195, 220, 240); // smaller belly                       [ 3] 
    g.setColor(new Color(240, 200, 40)); // some gold 
    g.fillOval( 85-left, 390, 175,  80); // right foot (left)                   [ 4] 
  }
}

https://cdna.4imprint.com/prod/700/169244.jpg

Compile with Tuesday.java 

cjdummer

At the end of the lecture we should look at this: 

import java.awt.Graphics;
import javax.swing.JFrame;

public class Tuesday {
  public static void main(String[] args) {
    JFrame a = new JFrame(); 
    int width = 500, height = 500; 
    a.setVisible(true); 
    a.setSize(width+20, height+40); 
    // how can you determine 20, 40 dynamically? 
    Penguin b = new Penguin(width, height); 
    a.add(b);     
  }
}

There are two classes, the one above is the smaller one (setting up the infrastructure).

import javax.swing.JComponent;
import java.awt.Graphics; 
import java.awt.Color;
import java.awt.Polygon;

public class Penguin extends JComponent {
  int width, height; 
  public Penguin(int width, int height) {
    this.width = width;
    this.height = height; 
  }
  public void paintComponent(Graphics g) {
    // default color is Color.BLACK 
    g.drawOval(  0,   0, 500, 500); // circle in the background (not necessary) [ 0] 
    g.setColor(Color.WHITE); 
    g.fillRect(  0,   0, 500, 500); // background (see marks by circle)         [ 0] 
    g.setColor(Color.BLACK);        // used by body                             [ 1] 
    g.fillPolygon( new Polygon // put this last                                 [11] 
                    ( new int[] {  10, 265, 499 }, 
                      new int[] { 274,  60, 274 }, 
                      3
                    )
                 );
    int left = 5;
    g.fillOval( 80-left,  50, 365, 400); // body                                [ 1] 
    g.setColor(new Color(220, 220, 220)); 
    g.fillOval(120-left, 190, 290, 250); // larger belly                        [ 2] 
    g.setColor(Color.WHITE); 
    g.fillOval(155-left, 195, 220, 240); // smaller belly                       [ 3] 
    g.setColor(new Color(240, 200, 40)); // some gold 
    g.fillOval( 85-left, 390, 175,  80); // right foot (left)                   [ 4] 
    g.setColor(new Color(240, 200, 40)); 
    g.fillOval(285-left, 390, 175,  80); // left foot (right)                   [ 5] 
    g.setColor(new Color(255, 255, 255)); 
    g.fillOval(170-left,  74,  92, 117); // right eye (left)                    [ 6] 
    g.setColor(new Color(255, 255, 255)); 
    g.fillOval(264-left,  94, 107,  79); // left eye (right)                    [ 7] 
    g.setColor(Color.BLACK);  
    g.fillOval(230-left, 120,  25,  33); // right eye pupil (left)              [ 8] 
    g.fillOval(270-left, 124,  17,  23); // left eye pupil (right)              [ 9] 
    g.setColor(new Color(240, 200, 40)); // gold as feet
    g.fillArc (188-left, 173, 150, 150, 55,  65); // bill, beak                 [10] 
  }
}

This second class does most of the relevant work.

--