Guest User

Untitled

a guest
Jan 15th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. public class Student {
  2.  
  3. private final String studentName;
  4. private final int rollNo;
  5. private int grade;
  6. private Book book;
  7. public boolean issuedBook;
  8. static List<Student> student = new ArrayList<>();
  9.  
  10. static HashMap<Student, List<Book>> bookIssued = new HashMap<>();
  11.  
  12. public Student(String studentName, int rollNo) {
  13. this.studentName = studentName;
  14. this.rollNo = rollNo;
  15.  
  16. }
  17.  
  18.  
  19. public void setGrade(int grade) {
  20. this.grade = grade;
  21. }
  22.  
  23. public String getName() {
  24. return studentName;
  25. }
  26.  
  27. public int getRollNo() {
  28. return rollNo;
  29. }
  30.  
  31. public int getGrade() {
  32. return grade;
  33. }
  34.  
  35. public static void main(String[] args) {
  36. System.out.println("Enter your name");
  37. Scanner input = new Scanner(System.in);
  38. String studentName = input.nextLine();
  39. int rollNo = input.nextInt();
  40. student.add(new Student(studentName, rollNo));
  41. System.out.println("Which book ya' wanna issue?");
  42. String bookToBeIssued = input.nextLine();
  43. //bookIssued.put(studentName,bookToBeIssued);
  44.  
  45.  
  46.  
  47. for (Map.Entry<String, String> entry : bookIssued.entrySet()) {
  48. String key = entry.getKey();
  49. String value = entry.getValue();
  50.  
  51. System.out.println("Student "+key+" has issued "+value);
  52. }
  53.  
  54.  
  55. }
  56.  
  57.  
  58.  
  59.  
  60. }
Add Comment
Please, Sign In to add comment