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()); }
public static void main(String[] args) { Student student = new Student(); student.firstName = "Mark"; student.middleName = "Elliot"; student.lastName = "Zuckerberg"; printFullName(student); }
@Test public void canSetUsername() { student.setUsername(USERNAME); assertEquals(USERNAME, student.getUsername()); }
public void Show() { for (Student temp : student) { System.out.println("First Name:" + temp.getFName() + "\tLast Name :" + temp.getLName()); System.out.println("Age is :" + temp.getAge()); System.out.println("College :" + temp.getCollege()); } }
public Student mapRow(ResultSet rs, int rowNum) throws SQLException { Student student = new Student(); student.setId(rs.getInt("id")); student.setName(rs.getString("name")); student.setAge(rs.getInt("age")); return student; }
/** readStudentDetail is a function which is read student detail from file and store in queue */ public void readStudentDetail() { try { // Reading the student detail stored in the txt file BufferedReader br = new BufferedReader( new FileReader( "C:/Users/khemanshu/workspace/Assignment/src/QueueImplemetation/students.txt")); while ((line = br.readLine()) != null) { String[] token = line.split(","); if (token.length < 2) continue; Student student = new Student(); student.setName(token[0]); student.setRank(Integer.parseInt(token[1])); studentsList.add(student); } br.close(); } catch (FileNotFoundException e) { System.out.println(e); } catch (IOException e) { System.out.println(e); } Collections.sort( studentsList, new StudentRankComparater()); // this function sort the student list according to rank of // student. for (Student student : studentsList) { studentQueue.enqueue(student); // storing the student objects in a student queue } }
@Override public void notice() { for (int i = 0; i < students.size(); i++) { Student student = (Student) students.get(i); student.update(); } }
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub // ServletConfig conf=getServletConfig(); PrintWriter out = response.getWriter(); ServletContext ctx = getServletContext(); String place = ctx.getInitParameter("pl"); String email = ctx.getInitParameter("em"); String name = ctx.getInitParameter("nm"); Student s = new Student(); s.id = 12; s.name = "raju"; ctx.setAttribute("stu", s); String[] frtArr = {"mango", "orange", "grapes"}; ctx.setAttribute("arr", frtArr); out.println( "<html><body bgcolor='yellow'>" + "<h1>ONE</h1>" + "<p>" + place + "<br>" + email + "<br>" + name + "</p>" + "<a href='TwoServ'>two</a>" + "</body></html>"); out.close(); }
/** * 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--; } }
public Student getStudentById(int Id) { SQLiteDatabase db = dbHelper.getReadableDatabase(); String selectQuery = "SELECT " + Student.KEY_ID + "," + Student.KEY_name + "," + " FROM " + Student.TABLE + " WHERE " + Student.KEY_ID + "=?"; // It's a good practice to use parameter ?, instead of concatenate string int iCount = 0; Student student = new Student(); Cursor cursor = db.rawQuery(selectQuery, new String[] {String.valueOf(Id)}); if (cursor.moveToFirst()) { do { student.student_ID = cursor.getInt(cursor.getColumnIndex(Student.KEY_ID)); student.name = cursor.getString(cursor.getColumnIndex(Student.KEY_name)); } while (cursor.moveToNext()); } cursor.close(); db.endTransaction(); db.close(); return student; }
public static double scoreSections(Model model) { Section sections[] = model.getAllSections(); double total = 0; for (Section s : sections) { double count = 0; double scount = 0; for (Student stu : s.getStudents()) { scount = scount + 1; if (stu.getPreferences()[0].equalsIgnoreCase("") || stu.getPreferences()[0] == null) { count = count + 1; } else { for (String pref : stu.getPreferences()) { if (pref.equalsIgnoreCase(s.getUniqueID())) { count = count + 1; break; } } } } // System.out.println("Sections " + s.getUniqueID() + " Score is " + // count/scount); total = total + (count / scount); } // System.out.println("Average score is " + total/33); return total / sections.length; }
public static void main(String[] args) throws Exception { // 1) primitive type 배열 int[] p = new int[5]; p[0] = 100; p[1] = 100; p[2] = 100; p[3] = 100; p[4] = 100; int[] p2 = p; System.out.printf("%d,%d\n", p2[0], p2[1]); // 2) 레퍼런스 배열 // Student s1, s2, s3; Student[] s = new Student[3]; s[0] = new Student(); s[1] = new Student(); s[2] = new Student(); Student[] s2 = s; Student obj1 = s2[2]; obj1.name = "오호라"; System.out.println(s[2].name); }
@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()); } }
public void printFriends() { System.out.println(getName() + "'s friends:"); for (Student f : favoriteFriends) { System.out.println(f.getName()); } System.out.println(); }
@Test public void getNameReturnsFullNameIfItIsSet() { student.setFullName(FULLNAME); assertEquals(FULLNAME, student.getName()); }
@Test public void setLoginSetsUsername() { student.setLogin(USERNAME); assertEquals(USERNAME, student.getUsername()); }
public void getStudStatus(List<Student> c, int id, Discipline d) { double average = 0; int count = 0; if (c.get(id).getMark(d) == 0) { System.out.println(c.get(id).getName() + " is not in group " + d); return; } for (Iterator<Student> iterator = c.iterator(); iterator.hasNext(); ) { Student student = (Student) iterator.next(); if (student.getMark(d) != 0) { average += student.getMark(d); count++; } } average = average / count; average = c.get(id).getMark(d) - average; String result = String.format("%.1f", Math.abs(average)); if (average < 0) { System.out.println( "Marks of " + c.get(id).getName() + " are " + result + " points worse than average in group " + d); } else if (average > 0) { System.out.println( "Marks of " + c.get(id).getName() + " are " + result + " points better than average in group " + d); } else System.out.println("Marks of " + c.get(id).getName() + " are group average."); }
public void deleteStudentFromClass(Student student) { for (Student st : listStudent) { if (st.equals(student)) { listStudent.remove(st); } } }
static int average(Student[] students) { // THIS not used -> static method candidate float tot = 0; // As static THIS is not passed for (Student s : students) { // Can be called without creating object statistics tot += s.average(); } return Math.round(tot / students.length); }
private void addStudent(StudentDirectory dir2, int i) { String id = "" + i; Student student = new Student(id); student.setId(id); student.addCredits(i); dir.add(student); }
private void assignStudent(Student s) { for (int y = 0; y < dorms.size(); y++) { if (s.hasRoom()) { break; } Dorm d = (Dorm) dorms.get(y); if (d.isFull()) { continue; } if (d.isFemaleOnly() && s.getGender() == Student.Gender.MALE) { continue; } int i = 0; while (i < d.getNumRooms()) { if (s.hasRoom()) { break; } try { d.getRoomByIndex(i).addResident(s); } catch (IllegalArgumentException e) { } i++; } } }
@Test public void DecodingJsonText2() throws ParseException { Student student = new Student("xudachao", 100, 25); List<String> goodFriends = new ArrayList<String>(); goodFriends.add("chenchong"); goodFriends.add("duquan"); student.setGoodFriends(goodFriends); String studentString = JSONValue.toJSONString(student); System.out.println(studentString); // Student必须有无参构造函数,因为利用反射获取对象 Student parsedStudent = JSONValue.parse(studentString, Student.class); System.out.println(parsedStudent); // smart json 还没提供直接数组串转会数组的方法 String goodFriendsString = JSONValue.toJSONString(goodFriends); System.out.println(goodFriendsString); // parse的结果只有两种可能 JSONObject或JSONArray Object object = JSONValue.parse(studentString); if (object instanceof JSONObject) { System.out.println("It,s a json object."); } else { System.out.println("It,s a json array."); } }
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("취소하였습니다."); } }
@Test public void canSetPlainId() { student.setPlainId(PLAIN_ID); assertEquals(PLAIN_ID, student.getPlainId()); }
public static void main(String[] args) { Student st1 = new Student(12, "ramananda", "cserama"); st1.getInfomation(); Branch bn1 = new Branch("sarkar", "Dhaka"); bn1.getInfomation(); Employee emp1 = new Employee("Ahsu", "bkrcAhsu", "Mirpur"); emp1.getInfomation(); }
@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"; }
public static void main(String[] args) { Student student1 = new Student(1, "Ajay"); student1.display(); Student student2 = new Student(2, "Vishnu"); student2.display(); Student.print(); }
private void verifyStudentLookup(StudentDirectory dir, int i) { String id = "" + i; Student student = dir.findById(id); assertEquals(id, student.getId()); assertEquals(id, student.getLastName()); assertEquals(i, student.getCredits()); }
@Test public void idIsSetBasedOnUsername() { final String expectedId = Base64.encodeBase64URLSafeString(USERNAME.getBytes()); student.setUsername(USERNAME); assertEquals(expectedId, student.getId()); }
@Test public void getNameReturnsConcatenatedFirstAndLastNameIfNoFullNameSet() { student.setFirstName(FIRSTNAME); student.setLastName(LASTNAME); assertEquals(FIRSTNAME + " " + LASTNAME, student.getName()); }