Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! I am stuck on my java code and am unsure how to execute it. I've attached the UML Class diagram, instructions, and what the

Hello! I am stuck on my java code and am unsure how to execute it. I've attached the UML Class diagram, instructions, and what the expected output should be. What is the java code for this lab? Thanks in advance!

UML Class Diagram:

image text in transcribedimage text in transcribedimage text in transcribed

Instructions:

image text in transcribed

Expected Output:

image text in transcribed

Test_AssignmentHierarchy code:

/* * Lab 04 * * Code to test the Assignment class hierarchy * * This is a very "thin" testing process. Students are STRONGLY ENCOURAGED to add additional * test cases to this code. * * (c) 2020 Terri Davis */

public class Test_AssignmentHierarchy { /* * An array to hold various Assignment type objects is declared and instantiated GLOBALLY here. * This is POOR DESIGN, but simplifies the testing code, so it will be allowed. */ private static Assignment[ ] assigns = new Assignment[6]; public static void main( String[] args ) { /* * The executable code called in the next statement has been provided to students. * The following method call will execute a standards check of your Assignment.java code, * verifying that it meets MINIMUM CODING STANDARDS. * Please note that CODE THAT FAILS THIS STANDARDS CHECK WILL EARN A GRADE OF ZERO. */ // Lab04_StdsCheck.standardsCheck( ); /* * Call methods to individually test each of the classes in the hierarchy */ testAssignment( ); testQuiz( ); testProject( ); /* * Use an ENHANCED FOR LOOP to output the toString return for every object * in the (global) array */ System.out.printf( "%n%n\t\tObjects of Assignment Hierarchy%n%n" ); for( Assignment nextAssign: assigns ) { System.out.printf( "%s%n", nextAssign.toString( ) ); } // end enhanced for loop } // end main private static void testAssignment( ) { /* * Call the null constructor of the Assignment class to verify that it * (a) has been coded correctly * (b) returns the expected results for the object instantiated */ assigns[0] = new Assignment( ); /* * Call the Full constructor of the Assignment class to verify that it * (a) has been coded correctly * (b) returns the expected results for the object instantiated */ assigns[1] = new Assignment( "IS2041", "001", 20200215 ); } // end testAssignment private static void testQuiz( ) { /* * Call the null constructor of the Quiz class to verify that it * (a) has been coded correctly * (b) returns the expected results for the object instantiated */ assigns[2] = new Quiz( ); /* * Call the Full constructor of the Assignment class to verify that it * (a) has been coded correctly * (b) returns the expected results for the object instantiated */ assigns[3] = new Quiz( "ACC2003", "015", 20200131, "T-Accounts", 25, true ); } // end testQuiz private static void testProject( ) { /* * Call the null constructor of the Project class to verify that it * (a) has been coded correctly * (b) returns the expected results for the object instantiated */ assigns[4] = new Project( ); /* * Call the Full constructor of the Assignment class to verify that it * (a) has been coded correctly * (b) returns the expected results for the object instantiated */ assigns[5] = new Project( "IS2043", "005", 20200202, "Programming Assignment 01", false ); } // end testProject } // end Test_AssignmentHierarchy

Assignment code from Lab 02:

public class Assignment { private String assignCourse = null; private String assignSctn = null; private String assignType = null; private int assignDue = 0;

public Assignment(){}

public Assignment(String course, String sctn, String type, int due) { this.assignCourse = course; this.assignSctn = sctn; this.assignType = type; this.assignDue = due; }

public final String getAssignCourse() { return assignCourse; }

public final void setAssignCourse(String assignCourse) { this.assignCourse = assignCourse; }

public final String getAssignSctn() { return assignSctn; }

public final void setAssignSctn(String assignSctn) { this.assignSctn = assignSctn; }

public final String getAssignType() { return assignType; }

public final void setAssignType(String assignType) { this.assignType = assignType; }

public final int getAssignDue() { return assignDue; }

public final void setAssignDue(int assignDue) { this.assignDue = assignDue; }

public String toString() { return "A(n) " + this.getAssignType() + " is due on " + this.getAssignDue() + " for " + this.getAssignCourse() + "." + this.getAssignSctn(); } }

Attributes private assignCourse: String private assignSctn: String private assignDue: int Assignment 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 setAssignCourse course: String): void public setAssignSctn section: String): void public setAssignDuel due: int): void Mututor method for the assignCourse instance variable Mutator method for the assignSctn instance variable Mutator method for the assignDue instance variable public getAssignCoursel): String public getAssignSct(): String public getAssignDue(): int Accessor method for the assignCourse instance variable Accessor method for the assignSctn instance variable Accessor methd for the assignDue instance variable public toString(): String Returns a reference to a String object containing a complete description of this Assignment object NOTES: 1. The instance variable assignType has been removed. See sample output for modifications to toString method. 2. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 3. Mutator and accessor methods must always be named according to the Basic Coding Standards. This UML diagram follows those standards. 4. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. 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 Description Operations public Quiz(): Quiz 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: int, name: String, quests: int, retake: boolean ): Quiz public setQuizName name: String): void public setQuizNbrQuests( quests: int): void public setQuizRetake retake: boolean ): void Mututor method for the quizName instance variable Mutator method for the quizNbrQuest instance variable Mutator method for the quizRetake instance variable public getQuizName(): String public getQuizNbr Quests(): int public getQuizRetake(): boolean Accessor method for the quizName instance variable Accessor method for the quizNbrQuests instance variable Accessor method for the quizRetake instance variable public toString(): String Returns a reference to a string object containing a complete description of this Quiz object NOTES: 1. Mutator and accessor methods must be defined as "final" methods. There is no exception to this rule. 2. Mutator and accessor methods must always be named according to the Basic Coding Standards. This UML diagram follows those standards. 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" (ie., 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: int, desc: String team: boolean ): Project public setProjDescl desc: String): void public setProjGroup( group: boolean): void Mututor method for the projdesc instance variable Mutator method for the projGroup instance variable public getProjDesc(): String public getProjGroup(): boolean Accessor method for the projDesc instance variable Accessor method for the projGroup instance variable public toString(): String Returns a reference to a string object containing a complete description of this Assignment object NOTES: 1. Mutator and accessor methods must be defined as "final methods. There is no exception to this rule. 2. Mutator and accessor methods must always be named according to the Basic Coding Standards. This UML diagram follows those standards. 3. Direct access to instance variables/values is permitted ONLY through the appropriate mutator/accessor methods. Ever. Period. Lab 04 SuperClasses and SubClasses General Information Beginning from your solution for Lab 02, create a Class hierarchy including Assignment (supeclass), Quiz(subclass), and Project(subclass) classes. Instructions Modify class Assignment to meet the revised requirements described in the UML Class Diagrams attached to the assignment. Create two new subclasses, Quiz and Project, based on the superclass Assignment, according to the UML Class Diagrams attached to the assignment. This lab will adhere to the published Basic Coding Standards. Failure to follow the standards will result in an assignment grade of zero (O). Zip the three (3).java source files (Assignment.java, Quiz.java, and Project.java) into a compressed folder named Lab04 Submission. Include source code for the object classes only in the zipped folder. DO NOT include the test harness (TestAssignmentHierarchy.java), edit/backup versions (with the in the file type) of the source code, or compiled code (.class files); submission of either will result in a grade of zero (O). Submit only the zipped folder Lab04 Submission as an attachment to this assignment. Provided to You The following resources are provided: These instructions, including sample toString output The UML Class Diagrams for the Assignment hierarchy Atest harness to use in testing your Assignment hierarchy, including classes Quiz and Project. Requirements The provided UML Class Diagrams explain the requirements for the changes to Assignment.java and creation of the subclasses. In addition to the requirements described there, be aware of the requirements included in the Basic Coding Standards. Specifically be aware of the following: All set and get methods must use standard naming (i.e. "set" or "get" followed by the instance variable name, adjusted for proper camel casing). All get and set methods must be 'final methods. The only direct access to instance variable values is through the set and get methods; no other direct access is every permitted. Expected Output Execution of the provided test harness should produce the results shown here. Slight alterations of spacing or working within the toString return are acceptable, but order of data items must match that shown. The highlighted portion of the subclass output originates in the superclass toString method. *** Some number will appear here *** Assignment.java passed minimal standards check. Quiz.java passed minimal standards check. Project.java passed minimal standards check. Objects of Assignment Hierarchy Assignment is due on for null null Assignment is due on 20200215 for IS2041.001 Quiz is due on for null.null null has a questions. Retake(s) available: false Quiz is due on 20200131 for ACC2003.015 T-Accounts has 25 questions. Retake(s) available: true Project is due on for null.null Is null a group project: false Project is due on 20200202 for IS2043.005 Is Programming Assignment 01 a group project: false

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions