java - Previously messy task still a few errors I don't understand -


my task link

my problem bottom part of tutor class have created , these errors here

these 2 pieces of code:

public class ex5program {

public void start() {     tutor[] tutors = createtutorsarray();     printtutors(tutors);     printonleavelist(tutors);     updatetutordetails(tutors[1]);     printnewtutordetails(tutors[1]);     tutor tutorwithmostpapers = gettutorwithmostpapers(tutors);     printtutorwithmostpapers(tutorwithmostpapers); }  private tutor[] createtutorsarray() {     string[] nopapers = {};     string[] introductorypapers = {"compsci101", "compsci111"};     string[] corestage1papers = {"compsci101", "compsci105"};     string[] allstageonepapers = {"compsci111", "compsci101", "compsci105"};     string[] stagetwopapers = {"compsci210", "compsci220", "compsci225", "compsci230"};     tutor[] tutors = new tutor[7];     tutors[5] = new tutor("sad sack", 86302, introductorypapers, false);     tutors[4] = new tutor("crystal ball", 49123, introductorypapers, false);     tutors[2] = new tutor("earl lee riser", 40879, allstageonepapers, true);     tutors[3] = new tutor("tom katt", 50876, stagetwopapers, false);     tutors[1] = new tutor("candy kane", 30869, nopapers, false);     tutors[0] = new tutor("carrie oakey", 30987, corestage1papers, true);     tutors[6] = new tutor("sonny day", 49586, stagetwopapers, true);     return tutors; }  private void printtutors(tutor[] tutors) {     system.out.println("current tutors");     system.out.println("==============");     (int = 0; < tutors.length; i++) {         system.out.print(i + 1 + ". ");         system.out.println(tutors[i].tostring());     } }  private void printonleavelist(tutor[] tutors) {     system.out.println();     system.out.println("tutors on leave");     system.out.println("=========================");     (int = 0; < tutors.length; i++) {         if (tutors[i].isonleave()) {             system.out.println(tutors[i].getname());         }     } }   private void updatetutordetails(tutor tutor) {     tutor.setname("ali katt");     tutor.setstaffid(23456);     string[] stage1papers = {"compsci101", "compsci105", "compsci111"};     tutor.setpapers(stage1papers);     tutor.setonleave(true); }  private void printnewtutordetails(tutor tutor) {     system.out.println();     system.out.println("updated details");     system.out.println("===============");     system.out.println("name: " + tutor.getname());     system.out.println("id: " + tutor.getstaffid());     string[] papers = tutor.getpapers();     system.out.print("papers: ");     if (papers.length > 0) {         (int = 0; < papers.length; i++) {             system.out.print(papers[i] + " ");         }     } else {         system.out.print("none");     }     system.out.println();     if (tutor.isonleave()) {         system.out.println("currently on leave");     } }  private tutor gettutorwithmostpapers(tutor[] tutors) {     tutor tutorwithmostpaperssofar = tutors[0];     (int = 0; < tutors.length; i++) {         if (tutors[i].teachesmorepapersthan(tutorwithmostpaperssofar)) {             tutorwithmostpaperssofar = tutors[i];         }     }     return tutorwithmostpaperssofar; }  private void printtutorwithmostpapers(tutor tutorwithmostpapers) {     system.out.println();     system.out.println("most papers");     system.out.println("===========");     system.out.println(tutorwithmostpapers.getname() + " teaches more papers other tutor."); } 

}

public class tutor {  // instance variables  private string name; private int staffid; private string[] papers; private boolean onleave;  public tutor(string name, int staffid, string[] papers, boolean onleave) {     // complete constructor method     this.name = name;     this.staffid = staffid;     this.papers = papers;     this.onleave = onleave; } // insert getname() method here public string getname(){     return name; } // insert setname() method here public void setname(string name){     this.name = name; } // insert getstaffid() method here public int getstaff(){     return staffid; } // insert setstaffid() method here public void setstaffid(int staffid){     this.staffid = staffid; } // insert getpapers() method here; public  string[] getpapers(){     return papers; } // insert setpapers() method here public void setpapers(string[] papers){     this.papers = papers; } // insert isonleave() method here public boolean isonleave(){     return onleave; } // insert setonleave() method here public void setonleave(boolean onleave){     this.onleave = onleave; } // insert tostring() method here public string tostring(){     return name + "(staff id:"+staffid+")"; } // insert teachesmorepapersthan() method here public tutor teachesmorepapersthan(tutor other){     return(papers.length>other.papers.length); } } 

can please explain whats wrong can't find no google.

there problem setter:

public void setstaffid(int staffid){     this.staffid = staffid; } 

because staffid different variable staffid (differing in case), method nothing (it assigns member variable itself).

this setter has same problem:

public void setonleave(boolean onleave){     this.onleave = onleave; } 

with method:

public tutor teachesmorepapersthan(tutor other){     return(papers.length>other.papers.length); } 

you attempting return boolean comparison, have declared return tutor. think meant declare return boolean.

with line

system.out.println("id: " + tutor.getstaffid()); 

you attempting call getstaffid() on tutor, there no such method. closest find getstaff, think mean call.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -