- /**
- * Demonstrates inheritance and
interfaces
- *
- * @author TK Rogers
- * @version 02-22-11
- */
- import java.awt.* ;
//Abstract Window Toolkit (awt) contains graphic
elements
- import javax.swing.* ;
- import java.util.ArrayList ;
// Required for using ArrayLists
-
- public class
InheritanceInterfaceDemo extends JApplet {
- // Fields
- private
ArrayList <Student> scienceStudent = new
ArrayList <Student> ( ) ;
- private
final int LIST_SIZE = 4 ;
-
- public void
init ( ) {
- }
-
- public void
paint ( Graphics g ) {
- for (
int x = 0 ; x < LIST_SIZE ; x++ ) {
-
scienceStudent.add ( new Student ( ) ) ;
- }
-
- for (
int x = 0 ; x < LIST_SIZE ; x++ ) {
-
g.setColor ( Color.red ) ;
-
g.drawString ( "Student" + x +
" gpa = " + scienceStudent.get ( x ).gpa (
),100,( 100 + 15 * x ) ) ;
-
-
g.setColor ( Color.blue ) ;
-
g.drawString ( "Student" + x +
" weight = " + ( int
) scienceStudent.get ( x ).getWeight ( ) , 250 , ( 100 + 15 * x ) ) ;
-
}
- }
- }