Student Name: 8) Consider the following ciass definitions. public class LibraryID{ private String name; // Person's name private int ID; // Person's library ID # private ArrayList Books; // Loaned books public LibraryID (String n, int num) { name = n; ID = num; Books = new ArrayList(); } public int getID () { return ID; } public String getName() { return name; } /* CheckOut () and ReturnBook () methods not shown */ Complete the following override method, contained in the LibraryID class. Two LibraryID's are considered the same if their ID numbers are the same. public boolean equals (Object other) { if (other == null){ return false;} LibraryID o = (LibraryID) other; 9) Assuming the code written in 8 is correct, write the call to compare LibraryID one and two inside the if statement. LibraryID one = new LibraryID("Mankind", 106); LibraryID two = new LibraryID ("Mick Foley", 106); if System.out.println("ID's belong to the same person"); else System.out.println("ID's belong to the different people.");

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 17PE
icon
Related questions
Question
Student Name:
8) Consider the following ciass definitions.
public class LibraryID{
private String name; // Person's name
private int ID;
// Person's library ID #
private ArrayList<String> Books; // Loaned books
public LibraryID (String n, int num) {
name = n;
ID = num;
Books = new ArrayList<String>(); }
public int getID () {
return ID; }
public String getName() {
return name; }
/* CheckOut () and ReturnBook () methods not shown */
Complete the following override method, contained in the LibraryID class. Two LibraryID's are
considered the same if their ID numbers are the same.
public boolean equals (Object other) {
if (other == null){
return false;}
LibraryID o = (LibraryID) other;
9) Assuming the code written in 8 is correct, write the call to compare LibraryID one and
two inside the if statement.
LibraryID one = new LibraryID("Mankind", 106);
LibraryID two = new LibraryID ("Mick Foley", 106);
if
System.out.println("ID's belong to the same person");
else
System.out.println("ID's belong to the different people.");
Transcribed Image Text:Student Name: 8) Consider the following ciass definitions. public class LibraryID{ private String name; // Person's name private int ID; // Person's library ID # private ArrayList<String> Books; // Loaned books public LibraryID (String n, int num) { name = n; ID = num; Books = new ArrayList<String>(); } public int getID () { return ID; } public String getName() { return name; } /* CheckOut () and ReturnBook () methods not shown */ Complete the following override method, contained in the LibraryID class. Two LibraryID's are considered the same if their ID numbers are the same. public boolean equals (Object other) { if (other == null){ return false;} LibraryID o = (LibraryID) other; 9) Assuming the code written in 8 is correct, write the call to compare LibraryID one and two inside the if statement. LibraryID one = new LibraryID("Mankind", 106); LibraryID two = new LibraryID ("Mick Foley", 106); if System.out.println("ID's belong to the same person"); else System.out.println("ID's belong to the different people.");
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning