Parcourir la source

bookStatus(), returnBook(int)

- Added bookStatus() that will help main program to determine if the
books are not past due
- Added returnBook(int) to remove the returned book from the List
- Fixed List<int> as List<Integer>
- Added import java.util.* for List and ArrayList
- Fixed status with status()
master
BinHong Lee il y a 8 ans
Parent
révision
95d4f4fbdd
1 fichiers modifiés avec 24 ajouts et 6 suppressions
  1. +24
    -6
      User.java

+ 24
- 6
User.java Voir le fichier

@@ -3,12 +3,14 @@
* Last edited : 6/4/2016
*/

import java.util.*;

class User
{
private String name;
private int id;
private int limit;
private List<int> books = new ArrayList<int>();
private List<Integer> books = new ArrayList<Integer>();

public User(String name, int id, int limit)
{
@@ -31,18 +33,20 @@ class User
{
if (books.size() < limit)
{
if (bookStatus)
{
return true;
}
return true;
}

return false;
}

public List<Integer> bookStatus()
{
return books;
}

public boolean borrowNewBook(int id)
{
if (status)
if (status())
{
books.add(id);
return true;
@@ -52,4 +56,18 @@ class User
return false;
}
}

public boolean returnBook(int id)
{
for (int i = 0; i < books.size(); i++)
{
if (books.get(i) == id)
{
books.remove(i);
return true;
}
}

return false;
}
}

Chargement…
Annuler
Enregistrer