Example #1
0
 @Test
 public void testBookAShouldEqualsBookBIfTheirNameAndISBNAreEqual() {
   Book a = new Book("TDD", 1234);
   Book b = new Book("TDD", 1234);
   assertTrue(a.equals(b));
   assertTrue(b.equals(a));
 }
Example #2
0
 public Book hasBook(Book k) {
   for (Book q : BookList) {
     if (k.equals(q)) {
       return q;
     }
   }
   return null;
 }
Example #3
0
 public void removeAllBooksByList(List<Book> tmpBookList) {
   for (Book k : BookList) {
     for (Book tmpK : tmpBookList) {
       if (k.equals(tmpK)) {
         BookList.remove(k);
       }
     }
   }
 }
  public void onClick(View v) {
    if (v.getId() == R.id.confirm) {
      // add code to remove the reservation

      dateFormat = new SimpleDateFormat("MM/dd/yyyy h:mm a", Locale.US);

      DateFormat transDateFormat = new SimpleDateFormat("MM/dd/yyyy");
      DateFormat transTimeFormat = new SimpleDateFormat("h:mm a");

      Long checkDate = null;
      Long returnDate = null;
      Date date = new Date();

      String resNum = "";

      for (Reservation temp : otterLibrary.reservations) {
        if (myBook.equals(temp.getReservedBook())) {
          System.out.println("they are equal");
          otterLibrary.availableBooks.add(
              myBook); // this should let the book be available for a hold again
          checkDate = temp.getCheckoutDate();
          returnDate = temp.getReturnDate();
          resNum = Integer.toString(temp.getReservationNumber());
        }
      }

      otterLibrary.addToLogs("----------------", "---------------");
      otterLibrary.addToLogs("Transaction Type: ", "Cancel Hold");
      otterLibrary.addToLogs("Customer's Username: "******"Book Title: ", myBook.getTitle());
      otterLibrary.addToLogs("Pickup Date: ", dateFormat.format(checkDate));
      otterLibrary.addToLogs("Return Date: ", dateFormat.format(returnDate));
      otterLibrary.addToLogs("Reservation Number: ", resNum);
      otterLibrary.addToLogs(
          "Transaction Date: ", transDateFormat.format(date)); // double check this
      otterLibrary.addToLogs("Transaction Time: ", transTimeFormat.format(date));
      otterLibrary.addToLogs("----------------", "---------------");

      Intent i = new Intent(this, MainActivity.class);
      startActivity(i);
    }
  }
Example #5
0
  ObjectsCompare() {
    Book b0 = new Book(1);
    Book b1 = new Book(1);
    Book b2 = b1;
    // porownuje sie referencje
    if (b1 == b2) {
      System.out.println("the same object");
    }
    // porowuje "zawartosc" obiektow
    if (b0.equals(b2)) {
      System.out.println("the same contents");
    }

    /** instanceof operator sprawdzanie czy X jest typu Y */
    String s = "sss";
    if (s instanceof String) {
      System.out.println("s is String");
    }
    if (s instanceof Object) { // ALWAYS true
      System.out.println("s is Object");
    }
  }
 public boolean has(Book otherBook, ArrayList<Book> listOfBooks) {
   for (Book book : listOfBooks) {
     if (book.equals(otherBook)) return true;
   }
   return false;
 }
Example #7
0
 @Test
 public void testBookAShouldNotEqualsBookBIfTheirISBNAreDifferent() throws Exception {
   Book a = new Book("TDD", 123);
   Book b = new Book("TDD", 1234);
   assertFalse(a.equals(b));
 }
Example #8
0
 @Test
 public void testBookAShouldNotEqualsBookBIfTheirNamesAreDifferent() {
   Book a = new Book("TDD", 1234);
   Book b = new Book("Refactor", 1234);
   assertFalse(a.equals(b));
 }
Example #9
0
 @Test
 public void testABookShouldEqualsItself() throws Exception {
   Book book = new Book("TDD", 1234);
   assertTrue(book.equals(book));
 }