Question: The project defines two classes: A Java class called Course (in Course.java) with certain attributes, and Another class called InstantiateUseArrayOfObjects (in InstantiateUseArrayOfObjects.java). This class creates

The project defines two classes:

A Java class called Course (in Course.java) with certain attributes, and

Another class called InstantiateUseArrayOfObjects (in InstantiateUseArrayOfObjects.java). This class creates 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.

The WriteCurrentRegistration() still needs to be coded.

Course.java

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; }

}

instantiateusearrayofobjects.java

package instantiateusearrayofobjects;

/** * * @author omora */ public class 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 } }

Output should look like the following:

Current course regitration: { IT2230, IT3345 } Current registration total credit = 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!