/* Author : Michael Robinson Program : inheritanceWebPage.java Purpose : This program uses multiple classes to make use of INHERITANCE. The class cssDefault.java is called the SUPER-CLASS and contains some methods that are inherited by other classes, by using the extends command in their signature. The classes WebPageHome, WebPage2, and WebPage3 are called SUB-CLASSES because they inherit/extends from the cssDefault SUPER-CLASS. These SUB-CLASSES can use all the methods of the SUPER- CLASS. At the same time these classes can have methods with the same names used in the SUPER-CLASS with different content. If a SUB-CLASS does this it is said that it is OVERIDING such method(s). SUB-CLASSES can have their own additional methods, not found in the SUPER- CLASS. The calling program that uses a SUB-CLASS, first checks to see if there are methods with the same name in the SUPER-CLASS, if there are, it will use the methods inside the SUB-CLASS overriding the methods in the SUPER-CLASS. Updated : July 31, 2099 */ import java.util.Scanner; import java.awt.*; //This is the calling program that uses the super-class and the //sub-classes. public class inheritanceWebPage { //this variable is private therefore it can not be inherited private static int end = -1; //this variable is public therefore it can be inherited public final double interestRate = .25; public static void page3() { System.out.println( " Welcome to WebPage3, these are your" + " settings:" ); //this is an external class which also is a sub-class webPage3 wp3 = new webPage3(); wp3.fontCSS(); wp3.colorCSS(); }//end public static void page3() public static void page2() { System.out.println( " Welcome to WebPage2, these are your" + " settings:" ); //this is an external class which also is a sub-class webPage2 wp2 = new webPage2(); wp2.fontCSS(); wp2.colorCSS(); }//end public static void page2() public static void home() //user enters 1 { System.out.println( " Welcome Home, these are your" + " settings:" ); //this is an external class which also is a sub-class webPageHome wpHome = new webPageHome(); wpHome.fontCSS(); wpHome.colorCSS(); }//end public static void home() //user enters 1 public static void menu() { System.out.println( "\n\n\t\t\t************************" ); System.out.println( "\t\t\t* Enter : *" + "\n\t\t\t* 0 to end program *" + "\n\t\t\t* 1 for HOME page *" + "\n\t\t\t* 2 for Page 1 *" + "\n\t\t\t* 3 for Page 2 *" ); System.out.println( "\t\t\t************************" ); }//end public static void menu() public static void controlMethod() { //creates and object to access the keyboard Scanner kb = new Scanner( System.in ); while( true ) { //this method accepts user manual input menu(); //reads the keyboard end = kb.nextInt(); if( end == 0 ) { break; } else if( end == 1 ) { home(); } else if( end == 2 ) { page2(); } else if( end == 3 ) { page3(); } }//end while(true) }//end public static void controlMethod() public static void welcome( int time, int recursion ) throws InterruptedException { int x = 0; String heading = "Welcome back --->"; System.out.print( "\t\t\t" ); for( x = 0; x < heading.length(); x++ ) { //prints one character at the time //from beginning to end System.out.print( heading.charAt(x) ); //program goes to sleep for time value //1000 = 1 second Thread.sleep( time ); } System.out.print( " " ); for( x = heading.length()-1; x > -1; x--) { //prints one character at the time //from end to beginning System.out.print( heading.charAt(x) ); //program goes to sleep for time value //1000 = 1 second Thread.sleep( time ); } System.out.println(); //calls the pause method in the SUPER-CLASS cssDefaults.pause(); if( recursion == 0 ) { //change font type, appearance and size Font font = new Font( "Verdana", Font.BOLD, 12 ); font = font.deriveFont( 20.0f ); welcome( 0, 1 ); } }//end public static void welcome(int time, int recursion)throws //InterruptedException public static void screenSize() { //creates an object called toolkit of the ToolKit class Toolkit toolkit = Toolkit.getDefaultToolkit(); //The Dimension Class encapsulates the height and width //values of a component. In this case is the screen's //height and width Dimension dim = toolkit.getScreenSize(); System.out.println( "\n\t\t\tYour Screen Dimensions Are:" ); System.out.println( "\t\t\tWidth : " + dim.width + " pixels" ); System.out.println( "\t\t\tHeight : " + dim.height + " pixels" ); }//end public static void screenSize() public static void main( String arg[] ) throws InterruptedException { welcome( 100, 0 ); screenSize(); controlMethod(); System.out.println( "Thank you!!" ); System.exit(0); }//end public static void main( String arg[] ) //throws InterruptedException }//end public class inheritanceWebPage