Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1) Create a class called Course that has the following instance variables: offered (boolean), id (String), name (String) and credits (int). In the Course class,
1) Create a class called Course that has the following instance variables: offered (boolean), id (String), name (String) and credits (int). In the Course class, you should do the following: a) Create a constructor method that takes appropriate parameters and sets the instance variables. b) Create getters for the instance variables. c) Create a tostring method for the course that prints out the course's details in the following 2) Create a class called Student that has the following instance variables: name (String), major (String), and courses (ArrayList Course ). In the Student class you should do the following: a) Create a constructor method that takes appropriate parameters and sets the name and major fields. b) Create a private static final variable in the class named MAX_CREDITS and set it to 18. c) Create getters and setters for the name and major fields and a getter for the courses field. d) Create a method called calculateCredits that calculates the total number of credits that student is taking. (i.e., add all the credits of the Course objects inside courses). e) Create a method called addCourse that takes a Course object as a parameter and adds that object to the current Student's courses. Ensure that the maximum number of credits taken will not be exceeded and that the course is currently being offered. The method returns a boolean that is true if the course is added successfully and false otherwise. f) Create a toString method for the course that prints out the Student name, major and all their currently registered courses. CSIS 130 American University of Kuwait 3) In your main class: g) Create yourself as a Student object and all current courses you are taking as Course objects. Register your courses to yourself. Print out the student's information using the toString created previously. h) Create a course that is not currently being offered. Attempt adding it. Print out the student's information. i) Attempt Exceeding the credit limit of the courses. Print out the student's information one last time
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started