final project q12 giveup
This commit is contained in:
27
finalproject/Question12/ControllerCreate.java
Normal file
27
finalproject/Question12/ControllerCreate.java
Normal file
@@ -0,0 +1,27 @@
|
||||
public class ControllerCreate extends Controller {
|
||||
public ControllerCreate(Library m) {
|
||||
super(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @param number
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public String create(String name, String number, int type) {
|
||||
try {
|
||||
int num = Integer.parseInt(number);
|
||||
if (type == 0) {
|
||||
m.addUser(new Lender(name, num));
|
||||
} else {
|
||||
m.addUser(new Borrower(name, num));
|
||||
}
|
||||
return "";
|
||||
} catch (NotALenderException e) {
|
||||
return e.getMessage();
|
||||
} catch (NumberFormatException e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user