Bläddra i källkod

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 8 år sedan
förälder
incheckning
95d4f4fbdd
1 ändrade filer med 24 tillägg och 6 borttagningar
  1. +24
    -6
      User.java

+ 24
- 6
User.java Visa fil

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

Laddar…
Avbryt
Spara