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<String> student = new ArrayList<>();
- static HashMap<String, String> 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();
- student.add(studentName);
- 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);
- }
- }
- }
- // Book class
- public class Book {
- private String[] bookName = {"Math", "English"};
- private boolean bookIssued;
- public boolean issueBook(Student student) {
- if (!student.issuedBook) {
- return false;
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment