Esempio n. 1
0
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }

      Id id = (Id) o;
      return number == id.number && customer.equals(id.customer);
    }
Esempio n. 2
0
  public List getListOfReturnableItems(Customer customer) {
    ArrayList listOfItemsLoanedByUser = new ArrayList();

    if (libraryItems.containsValue(customer)) {
      for (Map.Entry<Item, Customer> entry : libraryItems.entrySet()) {
        if (customer.equals(entry.getValue())) {
          listOfItemsLoanedByUser.add(entry.getKey());
        }
      }
    }
    return listOfItemsLoanedByUser;
  }
Esempio n. 3
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   SalesOrder other = (SalesOrder) obj;
   if (customer == null) {
     if (other.customer != null) return false;
   } else if (!customer.equals(other.customer)) return false;
   if (orderNumber == null) {
     if (other.orderNumber != null) return false;
   } else if (!orderNumber.equals(other.orderNumber)) return false;
   if (orderlines == null) {
     if (other.orderlines != null) return false;
   } else if (!orderlines.equals(other.orderlines)) return false;
   if (totalPrice == null) {
     if (other.totalPrice != null) return false;
   } else if (!totalPrice.equals(other.totalPrice)) return false;
   return true;
 }
  public static void main(String[] args) {
    String x = new String("Hello");
    Customer ram = new Customer(1001, "Ram");
    Customer ram2 = new Customer(1002, "Ram");
    if (ram.equals(ram2)) {
      System.out.println("Same Value");

    } else {
      System.out.println("Not Same Value");
    }
    Customer mike = new Customer(1002, "Mike");
    Customer tom = new Customer(1003, "Tom");
    System.out.println(ram.hashCode());
    System.out.println(mike.hashCode());
    System.out.println(tom.hashCode());
    System.out.println(x.toString());
    System.out.println(ram.toString());
    System.out.println(mike);
    System.out.println(tom);
  }
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;
    if (getClass() != obj.getClass()) return false;
    CustomerAddressImpl other = (CustomerAddressImpl) obj;

    if (id != null && other.id != null) {
      return id.equals(other.id);
    }

    if (address == null) {
      if (other.address != null) return false;
    } else if (!address.equals(other.address)) return false;
    if (addressName == null) {
      if (other.addressName != null) return false;
    } else if (!addressName.equals(other.addressName)) return false;
    if (customer == null) {
      if (other.customer != null) return false;
    } else if (!customer.equals(other.customer)) return false;
    return true;
  }
Esempio n. 6
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Reviews other = (Reviews) obj;
   if (customer == null) {
     if (other.customer != null) return false;
   } else if (!customer.equals(other.customer)) return false;
   if (date == null) {
     if (other.date != null) return false;
   } else if (!date.equals(other.date)) return false;
   if (readByAdmin != other.readByAdmin) return false;
   if (reported != other.reported) return false;
   if (text == null) {
     if (other.text != null) return false;
   } else if (!text.equals(other.text)) return false;
   if (worker == null) {
     if (other.worker != null) return false;
   } else if (!worker.equals(other.worker)) return false;
   return true;
 }
Esempio n. 7
0
 private boolean sameAsFormerCustomer(Customer newCustomer) {
   return customer == null ? newCustomer == null : customer.equals(newCustomer);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_book_select_cancel);

    Spinner bookSpinner = (Spinner) findViewById(R.id.bookSpinner);
    View select = findViewById(R.id.confirm);
    select.setOnClickListener(this);

    received = getIntent().getExtras();
    myCustomer = received.getParcelable("customer");
    ArrayList<Book> booksForSpinner = new ArrayList<>();

    for (Reservation temp : otterLibrary.reservations) {
      if (myCustomer.equals(temp.getReservedBy())) {
        booksForSpinner.add(temp.getReservedBook());
      }
    }

    List<String> titleList = new ArrayList<String>();
    for (int i = 0; i < booksForSpinner.size(); i++) {
      titleList.add(booksForSpinner.get(i).getTitle());
    }

    ArrayList<String> infoList = new ArrayList<String>();
    for (Book temp : booksForSpinner) {
      infoList.add("Author: " + temp.getAuthor());
      infoList.add("ISBN: " + temp.getIsbn());
      infoList.add("Hourly Fee: " + temp.getFormattedFee());
    }

    ArrayAdapter<String> dataAdapter =
        new ArrayAdapter<String>(this, R.layout.spinner_item, titleList);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    bookSpinner.setAdapter(dataAdapter);
    bookSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            TextView author = (TextView) findViewById(R.id.textView5);
            TextView isbn = (TextView) findViewById(R.id.textView7);
            TextView fee = (TextView) findViewById(R.id.textView8);

            String title = parent.getItemAtPosition(position).toString();
            System.out.println(title);

            for (Book temp : otterLibrary.books) {
              if (temp.getTitle().equals(title)) {
                author.setText("Author: " + temp.getAuthor());
                isbn.setText("ISBN: " + temp.getIsbn());
                fee.setText("Hourly Fee: " + temp.getFormattedFee());
                myBook = temp;
              }
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
  }