Created
July 1, 2011 20:16
-
-
Save vsoued/1059310 to your computer and use it in GitHub Desktop.
Testable wishlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package edu.brandeis.vogueable; | |
import java.util.ArrayList; | |
public class Wishlist { | |
private ArrayList<Item> wishlist; | |
public Wishlist(){ | |
wishlist = new ArrayList<Item>(); | |
} | |
public ArrayList<Item> showWishlist(){ | |
return wishlist; | |
} | |
public void addToWishlist(Item item){ | |
wishlist.add(item); | |
} | |
public Item getItemFromWishlist(){ | |
return wishlist.get(wishlist.size()-1); | |
} | |
public Item getItemFromWishlist(int i){ | |
return wishlist.get(i); | |
} | |
public Item getFirstItemFromWishlist(){ | |
return wishlist.get(0); | |
} | |
public Item getLastItemFromWishlist(){ | |
return wishlist.get(wishlist.size()-1); | |
} | |
public void removeFromWishlist(int i){ | |
wishlist.remove(i); | |
} | |
public void removeFromWishlist(Item item){ | |
wishlist.remove(item); | |
} | |
public void removeFirstItemFromWishlist(){ | |
wishlist.remove(0); | |
} | |
public void removeLastItemFromWishlist(){ | |
wishlist.remove(wishlist.size()-1); | |
} | |
public void clearWishlist(){ | |
wishlist.clear(); | |
} | |
public boolean wishlistContains(Item it){ | |
return wishlist.contains(it); | |
} | |
public int findItem(Item it){ | |
if (wishlist.contains(it)){ | |
return wishlist.indexOf(it); | |
}else{ | |
return -1; | |
} | |
public boolean wishlistEmpty(){ | |
return wishlist.isEmpty(); | |
} | |
public int wishlistSize(){ | |
return wishlist.size(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment