Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student {
- private final String studentName;
- private final int rollNo;
- private int grade;
- private Book book;
- public boolean issuedBook;
- static List<Student> student = new ArrayList<>();
- static HashMap<Student, List<Book>> bookIssued = new HashMap<>();
- public Student(String studentName, int rollNo) {
- this.studentName = studentName;
- this.rollNo = rollNo;
- }
- public void setGrade(int grade) {
- this.grade = grade;
- }
- public String getName() {
- return studentName;
- }
- public int getRollNo() {
- return rollNo;
- }
- public int getGrade() {
- return grade;
- }
- public static void main(String[] args) {
- System.out.println("Enter your name");
- Scanner input = new Scanner(System.in);
- String studentName = input.nextLine();
- int rollNo = input.nextInt();
- student.add(new Student(studentName, rollNo));
- System.out.println("Which book ya' wanna issue?");
- String bookToBeIssued = input.nextLine();
- //bookIssued.put(studentName,bookToBeIssued);
- for (Map.Entry<String, String> entry : bookIssued.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- System.out.println("Student "+key+" has issued "+value);
- }
- }
- }
Add Comment
Please, Sign In to add comment