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

Array of objects If you have questions please raise your hand. /Variables privat

ID: 3750698 • Letter: A

Question

Array of objects If you have questions please raise your hand. /Variables private String courseone The requirements are Coestructors Course)f I Cseate a class named Course(Course java The class must contsin peivate variables to represent the following information Course mber ( string tar? shich is beter?) in string float? which is better Course tite structor or fecuiry ng doat wbich is beter Schedule string tloat? which is better nstring loat? which is better) Room /Setter void sethane(String courseine) Example 7- Week2Courses [0/22-12/08) Getters reture couseane Jave version "1.8.931 ava HotSpot(TH) 64-8dt Serve, (bulld 25.31-be7, ai -) You ust add setters and gottes methods for each varisble Your progrmk you: How many classes are yos taking this semester? Yosr progrm t print all yo

Explanation / Answer

Course.java

public class Course {

//Declaring instance variables
private int number;
private String title;
private String faculty;
private String schedule;
private String room;

//Zero argumented constructor
public Course() {

}

//Parameterized constructor
public Course(int number, String title, String faculty, String schedule,
String room) {
this.number = number;
this.title = title;
this.faculty = faculty;
this.schedule = schedule;
this.room = room;
}

//getters and setters
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFaculty() {
return faculty;
}
public void setFaculty(String faculty) {
this.faculty = faculty;
}
public String getSchedule() {
return schedule;
}
public void setSchedule(String schedule) {
this.schedule = schedule;
}
public String getRoom() {
return room;
}
public void setRoom(String room) {
this.room = room;
}

//toString method is used to display the contents of an object inside it
@Override
public String toString() {
System.out.printf("%5d %-15s %-20s %-10s %-8s ", number, title, schedule, faculty, room);
return "";
}


}

__________________

Test.java

import java.util.ArrayList;

public class Test {

public static void main(String[] args) {

//Creating an ArrayList which holds Course class Objects
ArrayList < Course > arl = new ArrayList < Course > ();

//Creating Course class Objects
Course c1 = new Course(1111, "Computer Science", "Paul James", "10:00 AM - 11:30 AM", "CSE 120");
Course c2 = new Course(2222, "Electronics Engineering", "Bob Gill", "02:00 PM - 03:30 PM", "CCE 121");
Course c3 = new Course(3333, "Mechanical Enginnering", "Sammy", "11:00 AM - 12:30 PM", "MEC 220");
Course c4 = new Course(4444, "Information technology", "Robert Wills", "04:00 PM - 05:30 PM", "IIF 342");

//Adding objects to ArrayList
arl.add(c1);
arl.add(c2);
arl.add(c3);
arl.add(c4);


//Displaying the output
System.out.println("Number Course Title Schedule Faculty Room No");
System.out.println("------- --------- ------- ------ -------");
for (int i = 0; i < arl.size(); i++) {
System.out.println(arl.get(i));
}


}

}

______________________

Output:

Number Course Title Schedule Faculty Room No

------- --------- ------- ------ -------

1111 Computer Science 10:00 AM - 11:30 AM Paul James CSE 120

2222 Electronics Engineering 02:00 PM - 03:30 PM Bob Gill CCE 121

3333 Mechanical Enginnering 11:00 AM - 12:30 PM Sammy MEC 220

4444 Information technology 04:00 PM - 05:30 PM Robert Wills IIF 342

_____Could you plz rate me well.Thank You

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