示例#1
0
 public String findByName(String partialName) {
   String string = new String();
   for (Customer c : map.values()) {
     if (c.getName().indexOf(partialName) >= 0) {
       string += c.toString() + "\n";
     }
   }
   return string;
 }
示例#2
0
 // For debugging
 public String toString() {
   StringBuilder sb = new StringBuilder();
   sb.append("\nid: " + review_id);
   sb.append("\nrating: " + star_rating);
   sb.append("\ntext: " + review_text);
   sb.append("\ntimestamp: " + timestamp);
   sb.append("\ncustomer_id: " + customer_id);
   sb.append("\ndish_id:" + dish_id);
   sb.append("\nCUSTOMER: \n" + customer.toString());
   return sb.toString();
 }
示例#3
0
  public void run() {
    System.out.println("java verison=" + System.getProperty("java.version"));

    ApplicationContext context = new ClassPathXmlApplicationContext("SpringBeans.xml");
    Customer customer = (Customer) context.getBean("CustomerBean");

    if (customer == null) {
      System.out.println("NULL :-(");
    } else {
      System.out.println("Not NULL :-)\n" + customer.toString());
    }
  }
示例#4
0
  public static void main(String[] args) {

    HiLoPriorityQueue<Customer> prq = new HiLoPriorityQueue<Customer>(10);
    HiLoPriorityQueue<Customer> hlq = new HiLoPriorityQueue<Customer>(10, 5);

    Customer c1 = new Customer("Rock", 999);
    Customer c2 = new Customer("Brock", 1);
    Customer c3 = new Customer("UnderTaker", 1000);

    // insert values in the queue
    hlq.add(c1);
    hlq.add(c2);
    hlq.add(c3);

    Customer c = hlq.remove();
    System.out.println("Customer removed from queue information :: " + c.toString());

    Iterator<Customer> itr = hlq.iterator();
    System.out.println("Looping through all the current elements of the queue :: ");
    while (itr.hasNext()) {
      Customer element = itr.next();
      System.out.println("Details :: " + element.toString());
    }
  }
  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);
  }
  public static int writeFile() {

    // Writer to output to file
    PrintWriter pwOutput;

    // To track records written
    int numWritten = 0;

    // Read in lines from file
    // While reading in, open stream to write to 2 files.
    try {

      // Prepare to write file
      pwOutput = new PrintWriter("newCustomers.txt");

      // Loop through wile inputString is not null (still has things to read)
      for (Customer customer : customerArray) {

        if (customer == null) {
          break;
        }
        // Output to big, add new line char behind
        pwOutput.write(customer.toString() + "\n");

        // Increment count
        numWritten++;
      }

      // Close stream
      pwOutput.close();

    } catch (Exception e) {

      // If there's an error, catch it and output to screen.
      System.out.println("Error: " + e);
    }

    return numWritten;
  }