ace

testitemclass1

ace
Aug 18th, 2010
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1.  
  2. /**
  3. * This is a test for the bomb squad game
  4. *
  5. * @author (your name)
  6. * @version (a version number or a date)
  7. */
  8. public class TestClass
  9. {
  10. // field for player1
  11. Player player1;
  12. Room room1;
  13. Item item1;
  14.  
  15. /**
  16. * Constructor for objects of class TestClass
  17. */
  18. public TestClass()
  19. {
  20. // initialise instance variables
  21. player1 = new Player();
  22. room1 = new Room("a test room.");
  23. item1 = new Item(3, "testItem", "item1");
  24.  
  25. }
  26.  
  27. /**
  28. * test take item method in player class
  29. */
  30. public String testTakeItem()
  31. {
  32. // put your code here"
  33. room1.setItems(item1);
  34. player1.setCurrentRoom(room1);
  35. player1.takeItem("item1");
  36. if (player1.checkInventory().equals ("testItem"))
  37. {
  38. return "test passes";
  39. }
  40. else
  41. {
  42. return "test fails";
  43. }
  44. }
  45.  
  46. public String testDropItem()
  47. {
  48. room1.setItems(item1);
  49. player1.setCurrentRoom(room1);
  50. player1.takeItem("item1");
  51. player1.dropItem("item1");
  52. if (room1.itemCheck("item1") == item1)
  53. {
  54. return "test passes";
  55. }
  56. else
  57. {
  58. return "test fails";
  59. }
  60. }
  61.  
  62. }
Add Comment
Please, Sign In to add comment