Ejemplo n.º 1
1
 public void display() {
   System.out.println("Name : " + student.getName());
   System.out.println("Age : " + student.getAge());
   System.out.println("Hobby : " + student.getHobby());
   System.out.println("height : " + student.getHeight());
   System.out.println("weight : " + student.getWeight());
 }
Ejemplo n.º 2
0
  @Test
  public void test1() throws Exception {

    Student denise = studentHome.create("823", "Denise Smith");

    Course power = courseHome.create("220", "Power J2EE Programming");

    Enroller enroller = enrollerHome.create();
    enroller.enroll("823", "220");
    enroller.enroll("823", "333");
    enroller.enroll("823", "777");
    enroller.enroll("456", "777");
    enroller.enroll("388", "777");

    System.out.println(denise.getName() + ":");
    ArrayList courses = denise.getCourseIds();
    Iterator i = courses.iterator();
    while (i.hasNext()) {
      String courseId = (String) i.next();
      Course course = courseHome.findByPrimaryKey(courseId);
      System.out.println(courseId + " " + course.getName());
    }

    System.out.println();

    Course intro = courseHome.findByPrimaryKey("777");
    System.out.println(intro.getName() + ":");
    courses = intro.getStudentIds();
    i = courses.iterator();
    while (i.hasNext()) {
      String studentId = (String) i.next();
      Student student = studentHome.findByPrimaryKey(studentId);
      System.out.println(studentId + " " + student.getName());
    }
  }
Ejemplo n.º 3
0
  public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("StoredProcedureBeans.xml");

    StudentJDBCTemplate studentJDBCTemplate =
        (StudentJDBCTemplate) context.getBean("studentJDBCTemplate");

    System.out.println("------Records Creation--------");
    studentJDBCTemplate.create("Zara", 11);
    studentJDBCTemplate.create("Nuha", 2);
    studentJDBCTemplate.create("Ayan", 15);

    System.out.println("------Listing Multiple Records--------");
    List<Student> students = studentJDBCTemplate.listStudents();
    for (Student record : students) {
      System.out.print("ID : " + record.getId());
      System.out.print(", Name : " + record.getName());
      System.out.println(", Age : " + record.getAge());
    }

    System.out.println("----Listing Record with ID = 2 -----");
    Student student = studentJDBCTemplate.getStudent(2);
    System.out.print("ID : " + student.getId());
    System.out.print(", Name : " + student.getName());
    System.out.println(", Age : " + student.getAge());
  }
  @Override
  public int compare(Student o1, Student o2) {
    String name1 = o1.getName();
    String name2 = o2.getName();

    // ascending order (descending order would be: name2.compareTo(name1))
    return name1.compareTo(name2);
  }
Ejemplo n.º 5
0
 public static boolean equals(Student s1, Student s2) {
   // if s1 name == s2 name and s1 score == s2 score
   if (s1.getName() == s2.getName() && s1.getScore() == s2.getScore()) {
     // student's are equal
     return true;
   } else {
     // student's are not equal
     return false;
   }
 }
Ejemplo n.º 6
0
  @Test
  public void test() {
    // fail("Not yet implemented");

    Student student1 = new Student("Jon");
    assertEquals("Jon", student1.getName());

    Student student2 = new Student("Joy");
    assertEquals("Joy", student2.getName());
  }
Ejemplo n.º 7
0
 @Test
 public void testsameiddifferentnameEquals() {
   System.out.println("equals");
   Student instance1 = new Student();
   instance1.setName("Ranjith");
   instance1.setId("c0663421");
   Student instance2 = new Student();
   instance2.setName("surya");
   instance2.setId("c0663421");
   assertFalse(instance1.getName().equals(instance2.getName()));
 }
  /**
   * showListOfStudent is a function which is used to print the student detail after allotement of
   * colleges.
   */
  void showListOfStudent() {
    int size = studentQueue.getSize();
    Student student = new Student();
    for (int count = 0; count < size; count++) {
      student = (Student) studentQueue.dequeue();
      if (student.getCollegeName() != null) {
        System.out.println(student.getName() + " ->" + student.getCollegeName());

      } else System.out.println(student.getName() + " ->" + "Not alloted any college");
      studentQueue.enqueue(student);
    }
  }
Ejemplo n.º 9
0
 private boolean existsInGroup(Student st) {
   boolean result = false;
   for (Student grStudent : this.students) {
     if (grStudent != null) {
       if (grStudent.getSirname().equals(st.getSirname())
           && grStudent.getName().equals(st.getName())
           && grStudent.getGender() == st.getGender()
           && grStudent.getAge() == st.getAge()) {
         result = true;
       }
     }
   }
   return result;
 }
Ejemplo n.º 10
0
  @Test
  public void getNameReturnsFullNameIfItIsSet() {

    student.setFullName(FULLNAME);

    assertEquals(FULLNAME, student.getName());
  }
  /**
   * SeatAllotment is a function which is used to allot a seat of desire college if seat is
   * available.
   */
  void SeatAllotment() {

    int collegeCounter = calculteTotalSeat();

    int sizeStudent = studentQueue.getSize();
    int sizeColllege = collegeQueue.getSize();
    Colleges colleges = new Colleges();
    Student student = new Student();

    while (sizeStudent != 0) {
      if (collegeCounter == 0) break;

      student = (Student) studentQueue.dequeue();

      System.out.println("Student Name ->" + student.getName() + "\n" + "Select any college");

      showListOfCollage();
      String name = ValidationForCollegeName();

      for (int count = 0; count < sizeColllege; count++) {
        colleges = (Colleges) collegeQueue.dequeue();
        if (colleges.getName().equalsIgnoreCase(name) == true) {
          student.setCollegeName(name);
          colleges.setSeatAvaliable(colleges.getSeatAvaliable() - 1);
        }

        collegeQueue.enqueue(colleges);
      }

      System.out.println("Allotement is successfully done");
      studentQueue.enqueue(student);
      sizeStudent--;
      collegeCounter--;
    }
  }
Ejemplo n.º 12
0
 public void deleteStudent(String name) {
   if (name.equals(studentListStart.getName())) {
     studentListStart = studentListStart.getNext();
     studentListStart.setPrev(null);
   } else {
     Student current = studentListStart;
     while ((current.getNext() != null) && (!name.equals(current.getName())))
       current = current.getNext();
     if (current == null) return;
     else {
       current.getPrev().setNext(current.getNext());
       current.getNext().setPrev(current.getPrev());
       return;
     }
   }
 }
 public void printFriends() {
   System.out.println(getName() + "'s friends:");
   for (Student f : favoriteFriends) {
     System.out.println(f.getName());
   }
   System.out.println();
 }
Ejemplo n.º 14
0
  @Test
  public void getNameReturnsConcatenatedFirstAndLastNameIfNoFullNameSet() {

    student.setFirstName(FIRSTNAME);
    student.setLastName(LASTNAME);

    assertEquals(FIRSTNAME + " " + LASTNAME, student.getName());
  }
  @RequestMapping(value = "/addStudent", method = RequestMethod.POST)
  public String addStudent(@ModelAttribute("SpringWeb") Student student, ModelMap model) {
    model.addAttribute("name", student.getName());
    model.addAttribute("age", student.getAge());
    model.addAttribute("id", student.getId());

    return "result";
  }
Ejemplo n.º 16
0
 @Test
 public void nameStudentTest() {
   System.out.println("StudentTest");
   Student instance = new Student("Bill Smith", "c0123456", "male", 89.3);
   assertEquals("Bill Smith", instance.getName());
   assertEquals("c0123456", instance.getId());
   assertEquals("male", instance.getGender());
   assertEquals(89.3, instance.getGrade(), 0.0);
 }
Ejemplo n.º 17
0
 @Test
 public void namevalueTest() {
   System.out.println("StudentTest");
   Student instance = new Student();
   String expResult = "Bill Smith";
   instance.setName(expResult);
   String result = instance.getName();
   assertEquals(expResult, result);
 }
Ejemplo n.º 18
0
 @POST
 @Path("/students/")
 public Response addStudent(Student s) {
   System.out.println("Entered inside the addcustomer method with name" + s.getName());
   s.setId(initid++);
   Students.put(s.getId(), s);
   Response r = Response.ok().build();
   return r;
 }
  @SuppressWarnings("resource")
  public static void main(String args[]) {
    ApplicationContext context = new ClassPathXmlApplicationContext("annotationrequiredspring.xml");

    Student student = (Student) context.getBean("student");

    System.out.println("Name : " + student.getName());
    System.out.println("Age : " + student.getAge());
  }
Ejemplo n.º 20
0
 @RequestMapping(value = "Login", method = RequestMethod.POST)
 public String login(
     @RequestParam(value = "no") String no,
     @RequestParam(value = "password") String password,
     HttpSession session,
     RedirectAttributes attr) {
   Student getS = this.studentService.selectByNo(no);
   boolean student = (getS != null) ? getS.getPassword().equals(password) : false;
   Teacher getT = this.teacherService.selectByNo(no);
   boolean teacher = (getT != null) ? getT.getPassword().equals(password) : false;
   Administrator getA = this.administratorService.selectByNo(no);
   boolean administrator = (getA != null) ? getA.getPassword().equals(password) : false;
   boolean exist = student || teacher || administrator;
   String identity =
       student ? "Student" : teacher ? "Teacher" : administrator ? "Administrator" : "";
   if (exist) {
     session.setAttribute("login", no);
     session.setAttribute("identity", identity);
   } else {
     session.setAttribute("login", "error");
     return "redirect:/";
   }
   switch (identity) {
     case "Student":
       session.setAttribute("Id", getS.getNo());
       session.setAttribute("username", getS.getName());
       session.setAttribute("btlink", "ContestSystem/Student/Registration");
       break;
     case "Teacher":
       session.setAttribute("Id", getT.getNo());
       session.setAttribute("username", getT.getName());
       session.setAttribute("btlink", "ContestSystem/Declaration");
       break;
     case "Administrator":
       session.setAttribute("no", getA.getNo());
       session.setAttribute("username", getA.getNo());
       session.setAttribute("btlink", "ContestSystem/Administrator");
       break;
   }
   Object obj = this.userService.getUserByKey("no", no);
   String UserType = obj.getClass().getSimpleName();
   switch (UserType) {
     case "Administrator":
       break;
     case "Teacher":
       attr.addFlashAttribute("UserBtnLink", "Declaration");
       break;
     case "Student":
       attr.addFlashAttribute("UserBtnLink", "Registration");
       break;
     default:
   }
   attr.addFlashAttribute("User", obj);
   attr.addFlashAttribute("UserType", UserType);
   return "redirect:/";
 }
	public static void parameterChanger(int daysLeft, Student student) 
	{
		daysLeft += 5;
		student.setName("Tom");
		
		System.out.println();
		System.out.println("the number of days left " + daysLeft);
		System.out.println("the student name is" + student.getName());
		
	}
Ejemplo n.º 22
0
 public Student find(String name) {
   Student result = null;
   for (Student student : this.students) {
     if (student.getName().equals(name)) {
       result = student;
       break;
     }
   }
   return result;
 }
Ejemplo n.º 23
0
  public static void main(String[] args) {
    StudentDao studentDao = new StudentDaoImpl();

    // print all students
    for (Student student : studentDao.getAllStudents()) {
      System.out.println(
          "Student: [RollNo : " + student.getRollNo() + ", Name : " + student.getName() + " ]");
    }

    // update student
    Student student = studentDao.getAllStudents().get(0);
    student.setName("Michael");
    studentDao.updateStudent(student);

    // get the student
    studentDao.getStudent(0);
    System.out.println(
        "Student: [RollNo : " + student.getRollNo() + ", Name : " + student.getName() + " ]");
  }
Ejemplo n.º 24
0
  public static double calculateCumulativeGPA(Student student) {
    double attemptedHours = 0.0d;
    double qualityPoints = 0.0d;

    Session session = HibernateUtilities.getSessionFactory().openSession();
    session.beginTransaction();

    Query query = session.getNamedQuery("AttemptedHours").setString("name", student.getName());

    attemptedHours = (double) query.uniqueResult();

    Query qp = session.getNamedQuery("QualityPoints").setString("name", student.getName());

    qualityPoints = (double) qp.uniqueResult();

    session.getTransaction().commit();
    session.close();

    return qualityPoints / attemptedHours;
  }
Ejemplo n.º 25
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());
   }
 }
Ejemplo n.º 26
0
 public synchronized boolean equals(java.lang.Object obj) {
   if (!(obj instanceof Student)) return false;
   Student other = (Student) obj;
   if (obj == null) return false;
   if (this == obj) return true;
   if (__equalsCalc != null) {
     return (__equalsCalc == obj);
   }
   __equalsCalc = obj;
   boolean _equals;
   _equals =
       true
           && ((this.age == null && other.getAge() == null)
               || (this.age != null && this.age.equals(other.getAge())))
           && ((this.id == null && other.getId() == null)
               || (this.id != null && this.id.equals(other.getId())))
           && ((this.name == null && other.getName() == null)
               || (this.name != null && this.name.equals(other.getName())));
   __equalsCalc = null;
   return _equals;
 }
Ejemplo n.º 27
0
  public String getRosterReport() {
    StringBuilder buffer = new StringBuilder();

    buffer.append(ROSTER_REPORT_HEADER);

    for (Student student : students) {
      buffer.append(student.getName());
      buffer.append(NEWLINE);
    }

    buffer.append(ROSTER_REPORT_FOOTER + students.size() + NEWLINE);

    return buffer.toString();
  }
  @Override
  public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof StudentViewHolder) {

      Student singleStudent = (Student) studentList.get(position);

      ((StudentViewHolder) holder).tvName.setText(singleStudent.getName());

      ((StudentViewHolder) holder).tvEmailId.setText(singleStudent.getEmailId());

      ((StudentViewHolder) holder).student = singleStudent;

    } else {
      ((ProgressViewHolder) holder).progressBar.setIndeterminate(true);
    }
  }
Ejemplo n.º 29
0
 public static void GameOver(Student player, Teacher teacher, int battles) {
   System.out.println("The classwork was overwhelming! Beaten by " + teacher.getName());
   System.out.println("Winner info:");
   System.out.println("Name: " + teacher.getName());
   System.out.println("Strength: " + teacher.getStrength());
   System.out.println("Hitpoints: " + teacher.getHP());
   teacher.showAbilities();
   System.out.println();
   System.out.println("Loser info:");
   System.out.println("Name: " + player.getName());
   System.out.println("Strength: " + player.getStrength());
   System.out.println("Hitpoints: " + player.getHP());
   System.out.println("Classes attended: " + battles);
   player.showPlayerInventory(false);
   System.exit(0);
 }
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//initiialize and int object
		int daysLeft = 10;
		Student student = new Student();
		student.setName("John");
		
		System.out.println("the number of days left " + daysLeft);
		System.out.println("the student name is " student.getName());
		
		//pass an int and an object to parameterchanger
		//and change the values
		parameterChanger(daysLeft, student);
		
		//after returning from parameterChanger print the values
		System.out.println();
		System.out.println("the number of days left " + daysLeft);
		System.out.println("the student name is" + student.getName());
	}