Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void markOnLoan() throws IOException{
- System.out.println("Items not on loan: "+(items.size()-amountOnLoan)); //on start, should return just items.size();
- try{
- Object[] possible = new Object[items.size()-amountOnLoan];//gets all possible options to mark on loan
- for(int i = 0; i < items.size();i++){
- if(items.get(i).getOnLoan() == false){
- possible[i] = items.get(i);
- }
- }
- Object temp = JOptionPane.showInputDialog(null,"Which Item would you like to loan out?", "Loan out item", 0, null, possible, possible[0]);
- if(temp != null){
- String tempN = JOptionPane.showInputDialog(null, "Who did you loan this item too?");
- if(tempN != null){
- String tempD = JOptionPane.showInputDialog(null, "When was this item loaned out?");
- if(tempD!=null){
- items.get(items.indexOf(temp)).markOnLoan(tempN, tempD);
- fileWriter(items);
- amountOnLoan = amountOnLoan + 1; //if the user hasn't pressed cancelby this point, should add 1 to the amount on loan
- }
- }
- }
- }catch(ArrayIndexOutOfBoundsException e){
- JOptionPane.showMessageDialog(null, "No items to loan.", "Error", JOptionPane.ERROR_MESSAGE);
- }
- System.out.println("Items now on loan: " + amountOnLoan);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement