Hello, I am designing a code in NetBeans and I have tried to code it correctly but I am getting errors to where my code

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Hello, I am designing a code in NetBeans and I have tried to code it correctly but I am getting errors to where my code

Post by answerhappygod »

Hello,
I am designing a code in NetBeans and I have tried to code itcorrectly but I am getting errors to where my code isn't compiling.Please see below the directions and the code and see where my codecan be corrected. If possible can you show where the codecompiled correctly in NetBeans?
The Assessment instructions:
Hello Here is the question that I have below:
In this assessment, you will design and code a Java consoleapplication that defines a class, extends it into two otherclasses, overrides the toString() for all three classes,instantiates the classes into three objects, invokes the toString()on these objects, and prints out the return value of eachtoString() invocation.
For this assessment, you will create a Java console application.Console projects in NetBeans should use the Ant build system. Tostart the project in NetBeans, go to the File menu in NetBeans andselect New Project... When the New Project dialog box opens, undercategories select Java with Ant and under Projects select JavaApplication. Click the Next button and on the next panel and namethe project. Click the Finish button and the Java source code willopen in the editing window.
Your program output should look like the sample output providedin the "Extend Java Classes and Override Their MethodsInstructions" course file. Complete instructions andrequired templates are included in the Resources.
Your assignment will be scored on the following criteria:
Hello I Am Designing A Code In Netbeans And I Have Tried To Code It Correctly But I Am Getting Errors To Where My Code 1
Hello I Am Designing A Code In Netbeans And I Have Tried To Code It Correctly But I Am Getting Errors To Where My Code 1 (87.62 KiB) Viewed 45 times
Hello I Am Designing A Code In Netbeans And I Have Tried To Code It Correctly But I Am Getting Errors To Where My Code 2
Hello I Am Designing A Code In Netbeans And I Have Tried To Code It Correctly But I Am Getting Errors To Where My Code 2 (81.23 KiB) Viewed 45 times
Hello I Am Designing A Code In Netbeans And I Have Tried To Code It Correctly But I Am Getting Errors To Where My Code 3
Hello I Am Designing A Code In Netbeans And I Have Tried To Code It Correctly But I Am Getting Errors To Where My Code 3 (69 KiB) Viewed 45 times
Show transcribed data
Expert Answer
Course.java
public class Course
{
//Defining attributes
String code;
int creditHours;
String title;
//Parameterized Constructor
public Course(String code, int creditHours, String title) {
this.code = code;
this.creditHours = creditHours;
this.title = title;
}
@Override
public String toString() {
return "Java class name ='Course' Course Code = " + code;
}
}
FlexPathCourse.java
public class FlexPathCourse extends Course {
String optionalResources;
public FlexPathCourse(String code, int creditHours, Stringtitle) {
super(code, creditHours, title); //Inherit Course classattribute using super() method
}
@Override
public String toString() {
return "Java class name = 'FlexPathCourse' Course Code ="+code;
}
}
GuidedPathCourse.java
public class GuidedPathCourse extends Course {
int duration;
String requiredResources;
public GuidedPathCourse(String code, int creditHours, Stringtitle) {
super(code, creditHours, title); //Inherit Course classattribute using super() method
}
@Override
public String toString() {
return "Java class name = 'GuidedPathCourse' Course code = " +code ;
}
U1A1_InheritOverridetoString.java
public class U1A1_InheritOverridetoString {
public static void main(String[] args) {
System.out.println("Teacheer's Copy");
// Making Course class object
Course course=new Course("TBA",3,"TBA");
System.out.println(course);
// Making FlexPathCourse class object
FlexPathCourse flexPathCourse=newFlexPathCourse("IT2230",3,"Introduction to Database System");
System.out.println(flexPathCourse);
// Making GuidedPathCourse class object
GuidedPathCourse guidedPathCourse=newGuidedPathCourse("ITFP4789",3,"Mobile Cloud ComputingDevelopment");
System.out.println(guidedPathCourse);
}
}
}
Below is the code in Netbeans that I compiled thatdidn't work
/*
* To change this license header, choose License Headers inProject Properties.
* To change this template file, choose Tools |Templates
* and open the template in the editor.
*/
package it.fp3349_beasleybrian_assessment.pkg1_attempt.pkg1;
public class CourseImpl extends Course {
public CourseImpl(String code, int creditHours,String title) {
super(code, creditHours, title);
public class Course
{
//Defining attributes
String code;
int creditHours;
String title;
//Parameterized Constructor
public Course(String code, int creditHours, String title) {
this.code = code;
this.creditHours = creditHours;
this.title = title;
}
@Override
public String toString() {
return "Java class name ='Course' Course Code = " + code;
}
}
FlexPathCourse.java
public class FlexPathCourse extends Course {
String optionalResources;
public FlexPathCourse(String code, int creditHours, Stringtitle) {
super(code, creditHours, title); //Inherit Course classattribute using super() method
}
@Override
public String toString() {
return "Java class name = 'FlexPathCourse' Course Code ="+code;
}
}
}
}
Extending Java Classes and Overriding Their Methods In this assessment, you will design and code a Java console application that defines a class, extends it into two other classes, overrides the toString() for all three classes, instantiates the classes into three objects, invokes the toString() on these objects, and prints out the return value of each toString() invocation. You can use either the Toolwire environment or your local Java development environment to complete this assignment. The requirements of this application are as follows. The application is to define a Java class called Course. The Course class has the following members: 1. code attribute - a string field to store the course code (e.g. IT4789) 2. creditHours attribute - an int field to store the credit hours of the course (e.g. 3) 3. title attribute - a string field to store the title of the course (e.g. Mobile Cloud Computing Application Development) 4. Parameterized constructor with the three parameters of code, creditHours, and title. The constructor simply assigns the received values to their corresponding attributes 5. An overridden toString() method that returns the name of the Java class (i.e. Course) and the course code assigned to the class object The application need to extend the Course class into two other Java classes named: 1. FlexPathCourse 2. GuidedPathCourse The FlexPathCourse class adds the following members:
The FlexPathCourse class adds the following members: 1. optional Resources attribute - a string field for the optional resources for a flexpath course 2. Parameterized constructor with the three parameters of code, creditHours, and title. The constructor simply assigns the received values to their corresponding attributes 3. An overridden toString() method that returns the name of the Java class (i.e. FlexPathCourse) and the course code assigned to the class object The GuidedPathCourse class adds the following members: 1. duration attribute - an int field for the duration of a guidedpath course 2. required Resources attribute - a string field for the required resources for a guidedpath course 3. Parameterized constructor with the three parameters of code, creditHours, and title. The constructor simply assigns the received values to their corresponding attributes 4. An overridden toString() method that returns the name of the Java class (i.e. GuidedPathCourse) and the course code assigned to the class object The application will then instantiates three objects from the Course, FlexPathCourse, and Guided PathCourse and invokes their corresponding toString() methods. Use these attribute values when instantiating the three classes to test your application:
Class Name Course FlexPathCourse GuidedPathCourse U1A1_InheritOverridetoString_Result-NetBeans IDE 8.1 File Edit View Navigate Source Refactor Run Debug Profile Team Tools Window Help <default config> ulal_nheritoverridetostring Course.java HexPathCourse jav GuidedPathCourse Java code TBD IT2230 U1A1 InheritOverride ITFP4789 Test Packages Libraries Test Libraries 20 21 creditHours Successful completion of this assignment will show the correct class name and course code printed out when the application is run. Your program output should look like this sample output: Projects x Files Services Start Page X U1A1 InheritOverridetoString Result.java X 6 USA1 InheritOverridetostring Result Source History 1-2-3374 Source Packages 3 3 Output-U1A1 InheritOverridetoString Result (run) 3 title TBD Introduction to Database Systems Mobile Cloud Computing Application Development Q Search (C140) Course javax FlexPathCourse.java X GuidedPathCourse.java X System.out.println("Teacher's Copy"); run: Teacher's Copy Java class name 'Course Course Code = TBD Java class name = 'GuidedPathCourse Course Code = IT2230 Java class name = 'FlexPathCourse Course Code = ITFP4789 BUILD SUCCESSFUL (total time: 0 seconds) X □ H AB H
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply