Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For Assignment, this class practice instantiating an already defined Java class

ID: 3728589 • Letter: F

Question

For Assignment, this class practice instantiating an already defined Java class into objects and invoke the attributes of those objects.  

1. Java class called Course with certain attributes:

2. The "WriteCurrentRegistration()" still needs to be coded below. This class create an array of course objects and initializes their attributes to specific values and then calls the WriteCurrentRegistration() to print the current list of registered classes and their total credit hours.

package u10d1_instantiateusearrayofobjects;

/**

*

* @author hollingsworth

*/

public class U10D1_InstantiateUseArrayOfObjects {

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        // TODO code application logic here

       

            Course[] courses = {

            new Course("IT1006", 6, false),

            new Course("IT4782", 3, false),

            new Course("IT4789", 3, false),

            new Course("IT4079", 6, false),

            new Course("IT2230", 3, true),

            new Course("IT3345", 3, true),

            new Course("IT2249", 6, false)

        };

       

        WriteCurrentRegistration(courses);

    }

//This method prints the current list of registered courses thus far

    //from the courses array separated by , and enclosed inside { }

    //It also prints the total credit registered for thus far

    public static void WriteCurrentRegistration(Course[] courses) {

        //TODO:

        //loop over the courses array and print

        //the current list of registered courses

        //separated by , and enclosed inside { }

        //Also, print the total credit registered for

    }

   

}

Course Class:

package u10d1_instantiateusearrayofobjects;

/**

*

* @author hollingsworth

*/

public class Course {

    private String code = "";

    private int creditHour = 0;

    private boolean isRegisterdFor = false;

  

    public Course(String code, int creditHour, boolean isRegisteredFor){

        this.code = code;

        this.creditHour = creditHour;

        this.isRegisterdFor = isRegisteredFor;

    }

   

    public void setCode(String code){

        this.code = code;

    }

   

    public String getCode() {

        return this.code;

    }

   

    public void setCrditHour(int creditHour) {

        this.creditHour = creditHour;

    }

   

    public int getCreditHour() {

        return this.creditHour;

    }   

   

    public void setIsRegisteredFor(boolean trueOrFalse){

        this.isRegisterdFor = trueOrFalse;

    }

   

    public boolean getIsRegisteredFor() {

        return this.isRegisterdFor;

    }

   

}

Explanation / Answer

package u10d1_instantiateusearrayofobjects; /** * * @author hollingsworth */ public class U10D1_InstantiateUseArrayOfObjects { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Course[] courses = { new Course("IT1006", 6, false), new Course("IT4782", 3, false), new Course("IT4789", 3, false), new Course("IT4079", 6, false), new Course("IT2230", 3, true), new Course("IT3345", 3, true), new Course("IT2249", 6, false) }; WriteCurrentRegistration(courses); } //This method prints the current list of registered courses thus far //from the courses array separated by , and enclosed inside { } //It also prints the total credit registered for thus far public static void WriteCurrentRegistration(Course[] courses) { //TODO: //loop over the courses array and print //the current list of registered courses //separated by , and enclosed inside { } //Also, print the total credit registered for int total = 0; System.out.print("{"); for(int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote