COP 3804 Intermediate Java - COP3804pgm4c_4 Professor: Michael Robinson e-mail : michael.robinson@cs.fiu.edu - At the beginning of ALL YOUR PROGRAMS add the following: /********************************************************************* Author : Your Name Course : Java section. Example Java-1, Java-2, Java-3, or Java-4 Professor : Michael Robinson Program # : Program Name Purpose : Purpose/Description { A brief description of the program } Due Date : MM/DD/YYYY Certification: I hereby certify that this work is my own and none of it is the work of any other person. ..........{ your signature }.......... *********************************************************************/ -------------------------------------------------------------------------------- Worth 12 Points - 2 extra points above the total 100 points - Program must be named: yourLastNameFirstLetterOfYourFirstNamePgm4.java ex: robinsonMpgm4.java - Make sure the program is properly documented and aligned uniformally, according to our "JAVA Programming Rules", discussed in class and located at: http://users.cis.fiu.edu/~mrobi002/includes/JAVA_programmingRules I will take points off if you do not follow the programming instructions. Purpose of this program: ======================== Master the creation and implementation of: 1. Polymorphism begins at page 342 in our book 2. swap begins at page 301 in our book 3. sorting begins at page 303 in our book 4. Stacks begins at page 402 in our book 5. Queues begins at page 408 in our book See our book in page 361 for graphical representations, where PolySuper is a super class sub1 extends PolySuper sub2 extends PolySuper sub3 extends PolySuper objectBuilder extends PolySuper, sub1, sub2, sub3 polimorphicArrays extends calling program multiAccess extends calling program ------------------------------------------------------------------------- Polymorphism ------------ ------------------------------------ | robinsonMSuperPgm4 super-class | | method1 | | method2 | | method3 | ------------------------------------ ^ ^ ^ ----------------------------------- | sub1 | sub2 | sub3 | | Super1 | Super2 | Supper3 | ----------------------------------- ^ ----------------------- | robinsonMTheBuilder | | sub-class | ----------------------- ^ ----------------------- | robinsonMOverloader | | sub-class | ----------------------- ^ -------------------------- | robinsonMTheDriverPgm4 | | driver-class | -------------------------- ------------------------------------------------------------------------- QUESTIONS: 1a) Create a Super Class named lastNameFirstNameInitialSuperPgm4 containing: Worth 0.50 points ( sub-total points 0.50 ). I) method1 that accepts one int and can not be inherited displaying the int value received. Worth 0.50 points ( sub-total points 1.00 ). II) method2 that accepts two strings and displays them, and also displays I am super method2. Worth 0.50 points ( sub-total points 1.50 ). III) method3 that accepts nothing and displays I am super method3 ------------------------------------ | robinsonMSuperPgm4 super-class | | method1 | | method2 | | method3 | ------------------------------------ ------------------------------------------------------------------------- 1b) Worth 1.50 points ( sub-total points 3.00 ). Create three sub classes named sub1, sub2, and sub3 which are sub classes of the Super Class in question 1a, and are also Super Classes themselves, which can be inherited, each worth 0.50 points. ----------------------------------- | sub1 | sub2 | sub3 | | Super1 | Super2 | Supper3 | ----------------------------------- ------------------------------------------------------------------------- 1c) Worth 0.50 points ( sub-total points 3.5 ). Create a sub class named lastNameFirstInitialTheBuilder, which is a sub class of sub2/Super2 class and displays all methods of the lastNameFirstNameInitialSuperPgm4 super class ONLY plus the words: I am TheBuilder ----------------------- | robinsonMTheBuilder | | sub-class | ----------------------- ------------------------------------------------------------------------- 1d) Worth 0.50 points ( sub-total points 4 ). Write a sub-class program called lastNameFirstInitialOverloader containing all inheritable methods from your super class in question 1 ( lastNameFirstNameInitialSuperPgm4 ), connecting to sub2 in question 1b), overloading/overriding method2 by displaying "Hello I am the Overloader" ----------------------- | robinsonMOverloader | | sub-class | ----------------------- ------------------------------------------------------------------------- 1e) Worth 2 points ( sub-total points 6 ). Create a driver class (with a main method) named lastNameFirstNameInitialTheDriverPgm4 (example robinsonMTheDriverPgm4) using all methods in all classes from questions 1a, 1b, 1c and 1d. -------------------------- | robinsonMTheDriverPgm4 | | driver-class | -------------------------- ------------------------------------------------------------------------- 2) Worth 2 points ( sub-total points 8 ). Swap in Chapter 12 begins, at page 301 in our book. Using the swap program we learned in class, display the following numbers 784, 5, 123, 56 places them in order from the lowest to the highest and display the results. ------------------------------------------------------------------------- 3) Worth 2 points ( sub-total points 10 ). Sorting in Chapter 12 begins, at page 303 in our book. Create a single dimension array with you first and last name. Using a bubble sort display the contents of the above array in alphabetical order. ------------------------------------------------------------------------- 4) Worth 1 point ( sub-total points 11 ) Collections Stacks LIFO Create a program named: yourLastNameFirstLetterOfYourFirstNamePgm4Stacks.java ex: robinsonMpgm4Stacks.java a) Worth 0.10 Display your stack size saying: My current stack size is: ??? b) Worth 0.20 Add ANY 6 words into your stack After adding EACH word display: Adding WORD VALUE into the stack, current stack size = # WORD VALUE means any word you want c) Worth 0.10 Display: These are the items in my stack Full stack = [Word 6, Word 5, Word 4, Word 3, Word 2, Word 1] of size = (your stack size) d) Worth 0.20 Using a while loop, display: Using a while loop I am at location 6 which contains : Word 6 I am at location 5 which contains : Word 5 I am at location 4 which contains : Word 4 I am at location 3 which contains : Word 3 I am at location 2 which contains : Word 2 I am at location 1 which contains : Word 1 e) Worth 0.20 Using an enhanced for loop, display: Using an enhanced for loop I am at location 6 which contains : Word 6 I am at location 5 which contains : Word 5 I am at location 4 which contains : Word 4 I am at location 3 which contains : Word 3 I am at location 2 which contains : Word 2 I am at location 1 which contains : Word 1 f) Worth 0.10 Display: Using a while loop Using a while loop, delete all items in the stack, one by one, displaying: Item on top of the stack = ??? Amount of Items in stack = # deleting stack item = ?????? Items inside the stack = [?, ?, ......] stack size = # g) Worth 0.10 Display: Now we have an empty stack, size = 0, items = [] ------------------------------------------------------------------------- 5) Worth 1 point ( sub-total points 12 ) Collections Queues FIFO Create a program named: yourLastNameFirstLetterOfYourFirstNamePgm4Queues.java ex: robinsonMpgm4Queues.java a) Worth 0.10 Display your queue size saying: My current queue size is: ??? b) Worth 0.20 Add ANY 6 words into your queue After adding EACH word display: Adding WORD VALUE into the queue, current queue size = # WORD VALUE means any word you want c) Worth 0.10 Display: These are the items in my queue Full queue = [Word 1, Word 2, Word 3, Word 4, Word 5, Word 6] of size = (your queue size) d) Worth 0.20 Using a while loop, display: Using a while loop I am at location 1 which contains : Word 1 I am at location 2 which contains : Word 2 I am at location 3 which contains : Word 3 I am at location 4 which contains : Word 4 I am at location 5 which contains : Word 5 I am at location 6 which contains : Word 6 e) Worth 0.20 Using an enhanced for loop, display: Using an enhanced for loop I am at location 1 which contains : Word 1 I am at location 2 which contains : Word 2 I am at location 3 which contains : Word 3 I am at location 4 which contains : Word 4 I am at location 5 which contains : Word 5 I am at location 6 which contains : Word 6 f) Worth 0.10 Display: Using a while loop Using a while loop, delete all items in the queue, one by one, displaying: Item on top of the queue = ??? Amount of Items in queue = # deleting queue item = ?????? Items left inside the queue = [?, ?, ......] queue size = # g) Worth 0.10 Display: Now we have an empty queue, size = ?, items = [?????] ------------------------------------------------------------------------- Program submission: - ZIP folder containing the source code for all programs above, from questions 1, 2, 3, 4, and 5 - Upload your zipped folder to your Canvas account NOTE: If you have any question, please email me at michael.robinson@cs.fiu.edu We have face 2 face and online FREE tutoring from Monday thru Friday, please visit us, NO APPOINTMENTS NECESSARY. I have Office Hours twice a week. Please remember that we are here to help you succeed in your classes. -------------------------------------------------------------------------