vendredi 30 décembre 2016

Missing return statements, loops

A method I'm using requires loops, and I have managed to work myself into a corner trying to split up the loops up by adding new methods. I've pasted part of my code below. I'm currently receiving the error message "missing return statement" and although I realise why this is happening I am unsure as how to continue. Any help or suggestions would be appreciated! Thanks.

public String addJob(String cust,boolean onSite, boolean sHand, String lang)
 {   int nt = 100;

    if (customers.containsKey(cust))
    {
             if (0 >= getCustomerCredit(cust)) { 
             return " Customer over credit limit "; }

             if (nt >= getCustomerCredit(cust))
             {
                Job jb = new Job(cust, onSite, sHand, lang);
                job.put(jb, getNewJobNo());
                    if(lang != "English")
                      { 
                        isStaffAvailableWork(trnsltr);}
                    if(sHand == false)
                      { isStaffAvailableWork(clk);
                      }
                    else { isStaffAvailableWork(typst);
                      }

            }

    }
     else { 
           Customer c = new Customer(cust);
           customers.put(cust, ntnt);
           Job jb = new Job(cust, onSite, sHand, lang);
           job.put(jb, getNewJobNo());
                if(lang != "English")
                  { 
                    isStaffAvailableWork(trnsltr);}
                if(sHand == false)
                  { isStaffAvailableWork(clk);
                  }
                else { isStaffAvailableWork(typst);
                      }

    }    
 }

 public String isStaffAvailableWork(Staff stf)
 {    
      if (staff.containsKey(stf)&&(stf.isStaffAvailable()==true))
      { 
           jb.setJobStatusOnGoing();
           stf.setStaffBusy();
           jobNoAndstaffId.put(staff.get(stf), job.get(jb));
           return "Staff allocated: " + stf;

       }

      if (staff.containsKey(stf)&&(stf.isStaffAvailable()==false))
      { 
           jb.setJobStatusWaiting(); 
           return "Job Waiting";

       }
      else return null;
    }

Aucun commentaire:

Enregistrer un commentaire