Example #1
0
 private void doList() {
   Student student = null;
   for (int i = 0; i < students.size(); i++) {
     student = (Student) students.get(i);
     if (student == null) // 배열의 항목이 null인 경우, 다음 항목으로 바로 이동.
     continue;
     System.out.printf(
         "%d %s %s %s %s\n",
         i, student.getName(), student.getEmail(), student.getTel(), student.getCid());
   }
 }
Example #2
0
  private void doAdd() {
    Student student = new Student();

    System.out.print("이름? ");
    student.setName(scanner.nextLine());

    System.out.print("이메일? ");
    student.setEmail(scanner.nextLine());

    System.out.print("전화? ");
    student.setTel(scanner.nextLine());

    System.out.print("기수? ");
    student.setCid(scanner.nextLine());

    System.out.print("정말 저장하시겠습니까?(y/n)");
    String yesno = scanner.nextLine();
    if (yesno.toLowerCase().equals("y")) {
      if (students.add(student) == 0) {
        System.out.println("저장되었습니다.");
      } else {
        System.out.println("저장소가 모두 찼습니다.\n저장할 수 없습니다!");
      }
    } else {
      System.out.println("취소하였습니다.");
    }
  }
Example #3
0
  private void doDelete() {
    System.out.print("회원 번호? ");
    int no = Integer.parseInt(scanner.nextLine());

    System.out.print("정말 삭제하시겠습니까?(y/n)");
    String yesno = scanner.nextLine();
    if (yesno.toLowerCase().equals("y")) {
      if (students.remove(no) != null) {
        System.out.println("삭제하였습니다.");
      } else {
        System.out.println("유효하지 않은 번호입니다.");
      }
    } else {
      System.out.println("취소하였습니다.");
    }
  }