Explorar el Código

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 hace 8 años
padre
commit
95d4f4fbdd
Se han modificado 1 ficheros con 24 adiciones y 6 borrados
  1. +24
    -6
      User.java

+ 24
- 6
User.java Ver fichero

@@ -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;
}
}

Cargando…
Cancelar
Guardar