Advertisement
Samuel_Berkat_Hulu

ClassDataApp

Mar 29th, 2021
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of class ClassDataApp here.
  4.  *
  5.  * @author (your name)
  6.  * @version (a version number or a date)
  7.  */
  8. class ClassDataApp
  9.  {
  10.  public static void main(String[] args)
  11.  {
  12.  int maxSize = 100; // array size
  13.  ClassDataArray arr; // reference to array
  14.  arr = new ClassDataArray(maxSize); // create the array
  15.  // insert 10 items
  16.  arr.insert("Evans", "Patty", 24);
  17.  arr.insert("Smith", "Lorraine", 37);
  18.  arr.insert("Yee", "Tom", 43);
  19.  arr.insert("Adams", "Henry", 63);
  20.  arr.insert("Hashimoto", "Sato", 21);
  21.  arr.insert("Stimson", "Henry", 29);
  22.  arr.insert("Velasquez", "Jose", 72);
  23.  arr.insert("Lamarque", "Henry", 54);
  24.  arr.insert("Vang", "Minh", 22);
  25.  arr.insert("Creswell", "Lucinda", 18);
  26.  arr.displayA(); // display items
  27.  String searchKey = "Stimson"; // search for item
  28.  Person found;
  29.  found=arr.find(searchKey);
  30.  if(found != null)
  31.  {
  32.  System.out.print("Found ");
  33.  found.displayPerson();
  34.  }
  35.  else
  36.  System.out.println("Can't find " + searchKey);
  37.  System.out.println("Deleting Smith, Yee, and Creswell");
  38.  arr.delete("Smith"); // delete 3 items
  39.  arr.delete("Yee");
  40.  arr.delete("Creswell");
  41.  arr.displayA(); // display items again
  42.  } // end main()
  43.  } // end class ClassDataApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement