/* Author : Michael Robinson Program : polyMain.java Purpose : This class uses the SUPER-CLASS ToolsSPClass and some SUB-CLASSES to implement: polymorphism and inheritance Updated : July 31, 2099 */ public class PolyMain extends ToolsSPClass { public static void showPolymorphism() { //inherits from ToolsSPClass super-class pause( "Using ToolsSPClass full = new " + " FullSizeCarSBClass(); .. enter" ); pl( "---------------------------------------------------" ); //creates object "full" of ToolsSPClass data type //controlling sub-class FullSizeCarSBClass() ToolsSPClass full = new FullSizeCarSBClass(); full.setMyName( "I am testing the full size" ); pl( full.getMyName().toUpperCase() + " as an object" ); full.setMyName( "I am using substring method full size" ); pl( full.getMyName().substring(2, 15).toUpperCase().concat( " about time" ).toUpperCase() + " as a static" ); pl( "---------------------------------------------------\n"); pause( "Using ToolsSPClass sport = new SportCarSBClass();" + " .. enter" ); pl( "-------------------------------------------------" ); //creates object "sport" of ToolsSPClass data type //controlling sub-class SportCarSBClass() ToolsSPClass sport = new SportCarSBClass(); sport.setMyName( "I am testing the sports size as " + "an object" ); pl( sport.getMyName() ); sport.setMyName( "I am testing the sports size" ); pl( getMyName() + " as a static" ); pl( "-------------------------------------------------\n" ); pause( "Using ToolsSPClass mini = new MiniCarSBClass();" + " .. enter" ); pl( "-----------------------------------------------" ); //creates object "mini" of ToolsSPClass data type //controlling sub-class MiniCarSBClass() ToolsSPClass mini = new MiniCarSBClass(); mini.setMyName( "I am testing the mini size as an object" ); pl( mini.getMyName() ); mini.setMyName( "I am testing the mini size " ); pl( getMyName() + " as a static" ); pl( "-----------------------------------------------\n" ); pause( "Calling methods from different classes .. enter" ); pl( "-----------------------------------------------\n" ); pl( "" + full.getMyName().toUpperCase() ); pl( "" + sport.getMyName().toUpperCase() ); pl( "\nThe Maximum number of 6,2,3,18,8,12,15 is : " + full.max( 6,2,3,18,8,12,15 ) ); pl( "The Minimum number of 6,2,3,18,8,12,15 is : " + full.min( 6,2,3,18,8,12,15 ) ); pl( "-----------------------------------------------\n" ); }//end public static void showPolymorphism() public static void dataManipulation() { //calling methods from the ToolsSPClass super-class Object data[] = { 49, 33, 'a', "michael" }; pl(); pl( "I want to print backwards the following array of " + "Objects: " ); pl( data ); pl(); printBackwards( data ) ; pl(); pause( "Let's continue.." ); }//end public static void dataManipulation() public static void someMath() //tools from { //calling methods from the ToolsSPClass super-class System.out.println( "Adding ints 3, 5, 6 = " + addInts( 3, 5, 6 ) ); System.out.println( "Adding doubles 3, 5, 6 = " + addDoubles( 3, 5, 6 ) ); System.out.println( "Adding floats 3, 5, 6 = " + addFloats( 3, 5, 6 ) ); System.out.printf( "The average of 3, 5, 6 = %.02f", average( 3, 5, 6 ) ); pl(); pl( "The Maximun number of 6,2,3,18,8,12,15 is:" + max(6,2,3,18,8,12,15) ); pl( "The Minimum number of 6,2,3,18,8,12,15 is:" + min(6,2,3,18,8,12,15) ); pl(); pause( "Lets manipulate some data, press ..." + " well you know you know what to do ..." ); }//end public static void someMath() public static void whoAmI() { //calling methods from the ToolsSPClass super-class setMyName( "Michael" ); p( "Howdy my name is " ); pl( getMyName() ); pause( "Let's do some math, press any key to continue .." ); }//end public static void whoAmI() public static void main( String arg[] ) { whoAmI();; someMath(); dataManipulation(); showPolymorphism(); pl( "Thank you for using PolyMain, hope to see you " + "again soon" ); pl( "==================================================" + "======" ); }//end public static void main( String arg[] ) }//end public class polyMain extends toolsSPClass