Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need assistance in learning how to write programs using polymorphism. see https://www.chegg.com/homework-help/questions-and-answers/hello-stuck-java-code-unsure-execute--ve-attached-uml-class-diagram-instructions-expected--q44442830 for code used in previous assignment that we are supposed to use to

Need assistance in learning how to write programs using polymorphism.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

see https://www.chegg.com/homework-help/questions-and-answers/hello-stuck-java-code-unsure-execute--ve-attached-uml-class-diagram-instructions-expected--q44442830 for code used in previous assignment that we are supposed to use to adjust.

A test harness (which you will complete) to test your implementation of the DateFormat interface. Requirements 1. Review the provided UML Diagrams. The executable code for the class Event and the interface DateFormat are part of the provided materials for this lab; you are not required to write that code. 2. Modify classes Assignment, Quiz, Project as needed to meet the revised requirements described in the UML Class Diagrams attached to the assignment. (See the green highlighted portions of the UML diagrams.) 3. Add the necessary code to the Assignment hierarchy to permit those classes to use the DateFormat interface. 4. Make the required additions to Test Interface Implementation.java code: a. LINE 26: Add the declaration and instantiation of an array. i. The array must hold five (5) objects of class types that use the interface DateFormat. ii. The array must be marked as private that is, inaccessible outside the scope of the test code. iii. Keep in mind that main method of the test code accesses the array directly. This has implications for the declaration of the array. b. LINE 78: Add the control statement required to control the enhanced for loop here. 5. Be sure you have the following executables in your folder along with your modified code: a. DateFormat.class b. Event.class C. Lab@5_Stds_Check.class 6. Compile and execute your modified code. NOTE: Some standards violations will prevent the package from compiling. Compile error messages should assist in isolating the standards violations. Hints There are several ways to "break up" a String object into parts in order to rearrange those parts or reformat them. Chapter 14 of the text covers some of these methods. You are welcome to use whatever process you choose to do the "slicing and dicing needed to support the interface functionality. The code below is from the Event class source code and shows one way to solve the problem. String date = // retrieve date field from this object String year - date.substring(0, 4); // "slice" out year portion String month-date.substring( 4, 6); // "slice out month portion String day - date.substring( 6); // "slice" out day portion Once you have the "parts of the date, you can be rearrange and/or format as needed. A test harness (which you will complete) to test your implementation of the DateFormat interface. Requirements 1. Review the provided UML Diagrams. The executable code for the class Event and the interface DateFormat are part of the provided materials for this lab; you are not required to write that code. 2. Modify classes Assignment, Quiz, Project as needed to meet the revised requirements described in the UML Class Diagrams attached to the assignment. (See the green highlighted portions of the UML diagrams.) 3. Add the necessary code to the Assignment hierarchy to permit those classes to use the DateFormat interface. 4. Make the required additions to Test Interface Implementation.java code: a. LINE 26: Add the declaration and instantiation of an array. i. The array must hold five (5) objects of class types that use the interface DateFormat. ii. The array must be marked as private that is, inaccessible outside the scope of the test code. iii. Keep in mind that main method of the test code accesses the array directly. This has implications for the declaration of the array. b. LINE 78: Add the control statement required to control the enhanced for loop here. 5. Be sure you have the following executables in your folder along with your modified code: a. DateFormat.class b. Event.class C. Lab@5_Stds_Check.class 6. Compile and execute your modified code. NOTE: Some standards violations will prevent the package from compiling. Compile error messages should assist in isolating the standards violations. Hints There are several ways to "break up" a String object into parts in order to rearrange those parts or reformat them. Chapter 14 of the text covers some of these methods. You are welcome to use whatever process you choose to do the "slicing and dicing needed to support the interface functionality. The code below is from the Event class source code and shows one way to solve the problem. String date = // retrieve date field from this object String year - date.substring(0, 4); // "slice" out year portion String month-date.substring( 4, 6); // "slice out month portion String day - date.substring( 6); // "slice" out day portion Once you have the "parts of the date, you can be rearrange and/or format as needed. Expected Output Execution of the provided test harness should produce the results shown here. Slight alterations in spacing or of wording within the toString return are acceptable, but order of data items must match that shown. *** Some number will appear here *** Assignment.java passed minimal standards check. Quiz.java passed minimal standards check. Project.java passed minimal standards check. Event.java passed minimal standards check. Assignment implementation passes check Event implementation passes check Project implementation passes check Quiz implementation passes check Objects of Assignment Hierarchy Assignment is due on 03/01/2020 for GBA2013.007 Days remaining: 54 Quiz is due on 01/31/2020 for ACC2003.015 T-Accounts has 25 questions. Retake(s) available: true Days remaining: 24 Project is due on 02/02/2020 for IS2043.005 Is Programming Assignment 01 a group project: false Days remaining: 26 Event Graduation will take place on 05/23/2020 at AlamoDome. Days remaining: 137 Event Grad Program Info Session will take place on 02/21/2020 at NPB Room 3.01.10. Days remaining: 45 Attributes private assignCourse: String private assignSctn: String private assignDue: String Assignment (implements DateFormat) Notes The course number of the class for this assignment (e.g. IS2041, ACC2003, etc.) The section number of the class for this assignment (e.g., 001, EB1, etc.) The due date for this assignment in yyyymmdd format (e.g., 20200331 for March 30, 2020) Operations public Assignment(): Assignment Description A null constructor returning a reference to an Assignment object whose instance variables have all been set to "neutral defaults" (i.e., null String references or zeros) A full constructor, requiring one input parameter per instance value, returning a reference to an Assignment object whose instance variables have all been set to specified values public Assignment(course:String, sctn: String, due: int): Assignment public toString(): String Returns a reference to a String object containing a complete description of this Assignment object NOTES: 1. Accessor and mutator methods are not listed here, but are assumed to be present and to use standard naming. 2. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 3. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. 4. PLEASE NOTE: The type of the assignDue instance variable has been changed. Also - see sample output for change in toString output. Attributes private quizName: String private quizNbrQuests: int private quizRetake: boolean Quiz (subclass of Assignment) Notes A name identifying the quiz (e.g., Chapter 09, Review, etc.) The number of questions on the quiz May more than one attempt be made for this quiz? True or false Operations public Quiz(): Quiz Description A null constructor returning a reference to an Quiz object whose instance variables have all been set to "neutral defaults" (i.e., null String references or zeros) This constructor must call the superclass null constructor A full constructor, requiring one input parameter per instance value, returning a reference to an Quiz object whose instance variables have all been set to specified values The superclass full constructor must be called from this full constructor public Quiz( course: String, sctn: String, due: String, name: String, quests: int, retake: boolean ): Quiz public toString(): String Returns a reference to a string object containing a complete description of this Quiz object NOTES: 1. Accessor and mutator methods are not listed here, but are assumed to be present and to use standard naming. 2. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 3. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. Attributes private projDesc: String private projGroup: boolean Project (a subclass of Assignment) Notes A description of the project; may be verbose Is this a team project or individual? True = team; false = individual Operations public Project(): Project Description A null constructor returning a reference to an Project object whose instance variables have all been set to "neutral defaults" (i.e., null String references or zeros) This constructor must call the superclass null constructor A full constructor, requiring one input parameter per instance value, returning a reference to an Project object whose instance variables have all been set to specified values The superclass full constructor must be called from this full constructor public Project( course: String, sctn: String due: String, desc: String, team: boolean ): Project public toString(): String Returns a reference to a string object containing a complete description of this Assignment object NOTES: 1. Accessor and mutator methods are not listed here, but are assumed to be present and to use standard naming. 2. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 3. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. Attributes private eventName: String private eventBldg: String Event (implements DateFormat) Notes The name of the event (e.g., "Health Svcs Blood Drive") The building (or other location) at which the event will be held (e.g. "BB" for the Business Building, "NPB" for North Paseo Building) The room in which the event will be held (e.g.,3.01.10). If there is no room (for example, if the event is held in the Convocation Center), this will be a null reference. private eventRoom: String private eventDate: String The event date in yyyymmdd format (e.g., 20200512 for May 12, 2020) Operations public Event(): Event Description A null constructor returning a reference to an Event object whose instance variables have all been set to "neutral defaults" (i.e., null String references or zeros) public Event( name: String, bldg: String, room: String, date: String): Event A full constructor, requiring one input parameter per instance value, returning a reference to an Event object whose instance variables have all been set to specified values public formatDateShort(): String As required by interface DateFormat public toString(): String Returns a reference to a String object containing a complete description of this Assignment object NOTES: 1. Accessor and mutator methods are not listed here, but are assumed to be present and to use standard naming. 2. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 3. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. Attributes DateFormat (interface) Notes Interfaces do not typically define attributes.... Operations public default formatTodayShort(): String public default formatTodayLong(): String public default formatDateDdMmYyyy( int year, int month, int day): String Description Returns a reference to a String object containing today's date (as per the processor clock) formatted as: MM/DD/YYYY Returns a reference to a String object containing today's date (as per the processor clock) formatted as: DAYNAM, MONTHNAME dd, yyyy (e.g.: MONDAY, JANUARY 6, 2020) Returns a reference to a String object containg a formatted date based on the year, month, and day values passed to the method. The formatted String includes the long- form month name, e.g.: 29 February, 2020. Date validation is managed within the method. Returns the difference, in calendar days, between today's date (as per the processor clock) and the date represented by the passed String reference. The passed date should be in the short format: MM/DD/YYYY. This method must be provided in implementor types. The String reference returned from this method must be in the short format: MM/DD/YYYY public defaul find DiffDays( String shortformat ): long public abstract formatDateShort(): String A test harness (which you will complete) to test your implementation of the DateFormat interface. Requirements 1. Review the provided UML Diagrams. The executable code for the class Event and the interface DateFormat are part of the provided materials for this lab; you are not required to write that code. 2. Modify classes Assignment, Quiz, Project as needed to meet the revised requirements described in the UML Class Diagrams attached to the assignment. (See the green highlighted portions of the UML diagrams.) 3. Add the necessary code to the Assignment hierarchy to permit those classes to use the DateFormat interface. 4. Make the required additions to Test Interface Implementation.java code: a. LINE 26: Add the declaration and instantiation of an array. i. The array must hold five (5) objects of class types that use the interface DateFormat. ii. The array must be marked as private that is, inaccessible outside the scope of the test code. iii. Keep in mind that main method of the test code accesses the array directly. This has implications for the declaration of the array. b. LINE 78: Add the control statement required to control the enhanced for loop here. 5. Be sure you have the following executables in your folder along with your modified code: a. DateFormat.class b. Event.class C. Lab@5_Stds_Check.class 6. Compile and execute your modified code. NOTE: Some standards violations will prevent the package from compiling. Compile error messages should assist in isolating the standards violations. Hints There are several ways to "break up" a String object into parts in order to rearrange those parts or reformat them. Chapter 14 of the text covers some of these methods. You are welcome to use whatever process you choose to do the "slicing and dicing needed to support the interface functionality. The code below is from the Event class source code and shows one way to solve the problem. String date = // retrieve date field from this object String year - date.substring(0, 4); // "slice" out year portion String month-date.substring( 4, 6); // "slice out month portion String day - date.substring( 6); // "slice" out day portion Once you have the "parts of the date, you can be rearrange and/or format as needed. A test harness (which you will complete) to test your implementation of the DateFormat interface. Requirements 1. Review the provided UML Diagrams. The executable code for the class Event and the interface DateFormat are part of the provided materials for this lab; you are not required to write that code. 2. Modify classes Assignment, Quiz, Project as needed to meet the revised requirements described in the UML Class Diagrams attached to the assignment. (See the green highlighted portions of the UML diagrams.) 3. Add the necessary code to the Assignment hierarchy to permit those classes to use the DateFormat interface. 4. Make the required additions to Test Interface Implementation.java code: a. LINE 26: Add the declaration and instantiation of an array. i. The array must hold five (5) objects of class types that use the interface DateFormat. ii. The array must be marked as private that is, inaccessible outside the scope of the test code. iii. Keep in mind that main method of the test code accesses the array directly. This has implications for the declaration of the array. b. LINE 78: Add the control statement required to control the enhanced for loop here. 5. Be sure you have the following executables in your folder along with your modified code: a. DateFormat.class b. Event.class C. Lab@5_Stds_Check.class 6. Compile and execute your modified code. NOTE: Some standards violations will prevent the package from compiling. Compile error messages should assist in isolating the standards violations. Hints There are several ways to "break up" a String object into parts in order to rearrange those parts or reformat them. Chapter 14 of the text covers some of these methods. You are welcome to use whatever process you choose to do the "slicing and dicing needed to support the interface functionality. The code below is from the Event class source code and shows one way to solve the problem. String date = // retrieve date field from this object String year - date.substring(0, 4); // "slice" out year portion String month-date.substring( 4, 6); // "slice out month portion String day - date.substring( 6); // "slice" out day portion Once you have the "parts of the date, you can be rearrange and/or format as needed. Expected Output Execution of the provided test harness should produce the results shown here. Slight alterations in spacing or of wording within the toString return are acceptable, but order of data items must match that shown. *** Some number will appear here *** Assignment.java passed minimal standards check. Quiz.java passed minimal standards check. Project.java passed minimal standards check. Event.java passed minimal standards check. Assignment implementation passes check Event implementation passes check Project implementation passes check Quiz implementation passes check Objects of Assignment Hierarchy Assignment is due on 03/01/2020 for GBA2013.007 Days remaining: 54 Quiz is due on 01/31/2020 for ACC2003.015 T-Accounts has 25 questions. Retake(s) available: true Days remaining: 24 Project is due on 02/02/2020 for IS2043.005 Is Programming Assignment 01 a group project: false Days remaining: 26 Event Graduation will take place on 05/23/2020 at AlamoDome. Days remaining: 137 Event Grad Program Info Session will take place on 02/21/2020 at NPB Room 3.01.10. Days remaining: 45 Attributes private assignCourse: String private assignSctn: String private assignDue: String Assignment (implements DateFormat) Notes The course number of the class for this assignment (e.g. IS2041, ACC2003, etc.) The section number of the class for this assignment (e.g., 001, EB1, etc.) The due date for this assignment in yyyymmdd format (e.g., 20200331 for March 30, 2020) Operations public Assignment(): Assignment Description A null constructor returning a reference to an Assignment object whose instance variables have all been set to "neutral defaults" (i.e., null String references or zeros) A full constructor, requiring one input parameter per instance value, returning a reference to an Assignment object whose instance variables have all been set to specified values public Assignment(course:String, sctn: String, due: int): Assignment public toString(): String Returns a reference to a String object containing a complete description of this Assignment object NOTES: 1. Accessor and mutator methods are not listed here, but are assumed to be present and to use standard naming. 2. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 3. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. 4. PLEASE NOTE: The type of the assignDue instance variable has been changed. Also - see sample output for change in toString output. Attributes private quizName: String private quizNbrQuests: int private quizRetake: boolean Quiz (subclass of Assignment) Notes A name identifying the quiz (e.g., Chapter 09, Review, etc.) The number of questions on the quiz May more than one attempt be made for this quiz? True or false Operations public Quiz(): Quiz Description A null constructor returning a reference to an Quiz object whose instance variables have all been set to "neutral defaults" (i.e., null String references or zeros) This constructor must call the superclass null constructor A full constructor, requiring one input parameter per instance value, returning a reference to an Quiz object whose instance variables have all been set to specified values The superclass full constructor must be called from this full constructor public Quiz( course: String, sctn: String, due: String, name: String, quests: int, retake: boolean ): Quiz public toString(): String Returns a reference to a string object containing a complete description of this Quiz object NOTES: 1. Accessor and mutator methods are not listed here, but are assumed to be present and to use standard naming. 2. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 3. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. Attributes private projDesc: String private projGroup: boolean Project (a subclass of Assignment) Notes A description of the project; may be verbose Is this a team project or individual? True = team; false = individual Operations public Project(): Project Description A null constructor returning a reference to an Project object whose instance variables have all been set to "neutral defaults" (i.e., null String references or zeros) This constructor must call the superclass null constructor A full constructor, requiring one input parameter per instance value, returning a reference to an Project object whose instance variables have all been set to specified values The superclass full constructor must be called from this full constructor public Project( course: String, sctn: String due: String, desc: String, team: boolean ): Project public toString(): String Returns a reference to a string object containing a complete description of this Assignment object NOTES: 1. Accessor and mutator methods are not listed here, but are assumed to be present and to use standard naming. 2. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 3. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. Attributes private eventName: String private eventBldg: String Event (implements DateFormat) Notes The name of the event (e.g., "Health Svcs Blood Drive") The building (or other location) at which the event will be held (e.g. "BB" for the Business Building, "NPB" for North Paseo Building) The room in which the event will be held (e.g.,3.01.10). If there is no room (for example, if the event is held in the Convocation Center), this will be a null reference. private eventRoom: String private eventDate: String The event date in yyyymmdd format (e.g., 20200512 for May 12, 2020) Operations public Event(): Event Description A null constructor returning a reference to an Event object whose instance variables have all been set to "neutral defaults" (i.e., null String references or zeros) public Event( name: String, bldg: String, room: String, date: String): Event A full constructor, requiring one input parameter per instance value, returning a reference to an Event object whose instance variables have all been set to specified values public formatDateShort(): String As required by interface DateFormat public toString(): String Returns a reference to a String object containing a complete description of this Assignment object NOTES: 1. Accessor and mutator methods are not listed here, but are assumed to be present and to use standard naming. 2. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 3. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. Attributes DateFormat (interface) Notes Interfaces do not typically define attributes.... Operations public default formatTodayShort(): String public default formatTodayLong(): String public default formatDateDdMmYyyy( int year, int month, int day): String Description Returns a reference to a String object containing today's date (as per the processor clock) formatted as: MM/DD/YYYY Returns a reference to a String object containing today's date (as per the processor clock) formatted as: DAYNAM, MONTHNAME dd, yyyy (e.g.: MONDAY, JANUARY 6, 2020) Returns a reference to a String object containg a formatted date based on the year, month, and day values passed to the method. The formatted String includes the long- form month name, e.g.: 29 February, 2020. Date validation is managed within the method. Returns the difference, in calendar days, between today's date (as per the processor clock) and the date represented by the passed String reference. The passed date should be in the short format: MM/DD/YYYY. This method must be provided in implementor types. The String reference returned from this method must be in the short format: MM/DD/YYYY public defaul find DiffDays( String shortformat ): long public abstract formatDateShort(): String

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the components of an ANOV table?

Answered: 1 week ago