Java OOP Help

Soldato
Joined
8 Oct 2005
Posts
4,184
Location
Midlands, UK
Hi,

I'm reading a huge book about JAVA and have come to the oop stuff, unfortunately :( Now I'm going through some of their examples and follow the code through, but can honestly say I don't fully understand it.

The example is about inheritance and a parent (or super) classes. My understanding so far is that the Japplet class is the parent. The reason why the myApplet class works is because JApplet is the super class and the myApplet class has inherited the public JApplet methods. Is this correct or am I missing something major?

Code:
import java.awt.*;
public class Taxi {
    public void paint(Graphics g) {
          //This just draws a basic car
    }
}

import java.awt.*;
import javax.swing.*;
public class myApplet extends JApplet {
private Taxi taxi;
    public void init() {
        setSize(400, 250);
        taxi = new Taxi();
    }
    public void paint(Graphics g) {
        super.paint(g);
        taxi.paint(g);
    }  
}
 
Good :)

I understand it more when I'm referring to an Order super class and OrderItem sub class - as that makes more sense.
 
Back
Top Bottom