I wish to return a String as follows:
Josephine Blow (Associate Professor, Math)
Teaching Assignments: **(for each course write on a seperate line)**
Course No.: xxx \t Section No.: xxxx \t Course Name: xxxx \t Day and Time: dayOfWeek - timeOfweek
If no teaching assignments print: none
Using an ArrayList variable named "teaches", which from it I'm getting all my information.
I just can't understand how should I return this kind of a String, which can be very long. Should I use some kind of String buffer? How can I add the seperate line between each two sections.
Here's my code, for make it clear:
public String toString() {
String s ="";
int i=1;
if (this.teaches.isEmpty()){
return "none";
}
for(Section current: this.teaches){
s=s+"Course No"+i+" Section No:"+current.getSectionNo()+" Course Name:"+current.getRepresentedCourse().getCourseName()+" Day and Time"+current.getTimeOfDay();
}
return new String (this.getName()+" (Associatr Professor, "+this.department+" )"+s);
}