java - Object created in main doesnt perform in other classess -
I need help I stuck with this.
This is a class restaurant, I want to use my objects wtr1, wtr2, wtr3 which is a waiter class. I started them in my main.
Public category restaurant player {Private Final Vendors wtr1, wtr2, wtr3; Public restaurant (waiters wt1, wait wt2, waiters wt3) {super;) This.wtr1 = WT1; This.wtr2 = wt2; This.wtr3 = wt3; Calculate Public Float Salary () {employee employee = new employee (); Float wtrsal1 = 0; Float wtrsal2 = 0; Float wtrsal3 = 0; Float cell = 0; Switch (wtr1.wExp) {case "low": wtrsal1 = emp.salarywaiter [0]; break; Case "Medium": wtrsal1 = emp.salarywaiter [1]; break; Case "High": wtrsal1 = emp.salarywaiter [2]; break; } Switch (wtr2.wExp) {case "less": wtrsal2 = emp.salarywaiter [0]; break; Case "medium": wtrsal2 = emp.salarywaiter [1]; break; The case "high": wtrsal2 = emp.salarywaiter [2]; break; } Switch (wtr3.wExp) {case "less": wtrsal3 = emp.salarywaiter [0]; break; Case "Medium": wtrsal3 = emp.salarywaiter [1]; break; The case "high": wtrsal3 = emp.salarywaiter [2]; break; } Sal = wtrsal1 + wtrsal2 + wtrsal3; Refunds; }
And this is my main one. I do not know that the rest of the arguments should be nose, but it was set by default. The program does not exit, it gives me an error wt1.wExp is incorrect and it is System.out.println (rest.calculateSalary ());
is incorrect.
waiters wt1 = new waiter (19, 0); Waiters wt2 = new waiter (20, 0); Waiters wt3 = new waiter (21, 0); Restaurant rest = new restaurant (empty, null, void); Println (rest.calculateSalary ());
Here is the class of waiters:
public class waiter staff {String wname; String wsurname; String WEXp; Public waiter (int i, int n) {wname = getname (i); Wsurname = Friendly (i); WExp = expiration level [n]; }}
chit:
restaurant rest = New restaurant (empty, empty, empty);
The waiters you have made are not going, but are going through the tap, so what would you expect? In the example of the restaurant, there will be only zero
references and magically will not be able to use the waiter object. You must pass these - if you want to use the restaurant's references to the waiter, then pass them through the constructor.
waiter wt1 = new waiter (19, 0); Waiters wt2 = new waiter (20, 0); Waiters wt3 = new waiter (21, 0); Restaurant rest = new restaurant (wt1, wt2, wt3); Println (rest.calculateSalary ());
Comments
Post a Comment