Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using java language please need soluition as soon as posible Question 1 (20 points] Implement the class Student only. The code of the classes GradStudent

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

using java language please need soluition as soon as posible

Question 1 (20 points] Implement the class Student only. The code of the classes GradStudent and UndergradStudent is provided below. Student - id: int - name: String courses: ArrayList + Student(id: int, name: String) + getId(): int + getName(): String + setId(id: int): void + setName(name: String): void + getCourses():ArrayList + addCourse(cName: String): void + drop Course(cName: String): void + toString(): String UndergradStudent - nbOfCreditsEarned: int + UndergradStudent(id:int, name: String, nbOfCredits Earned: int) + getNbOfCreditsEarned(): int + setNbOfCreditsEarned(n: int): void + toString(): String GradStudent - foundInternship: boolean + GradStudent(id:int, name: String, foundInternship: boolean) + getFoundInternship(): boolean + setFoundInternship(f:boolean): void + toString(): String A. The Student class is characterized by three data fields: an int id, a String name, and an array list of String courses. Write the following methods: a) A constructor to initialize the id and the name data fields. b) Getters and setters (as shown in the UML). c) addCourse method that takes as parameter the name of the course to be added to the array list. d) dropCourse method that takes as parameter the name of the course to be deleted from the array list. e) A toString method to return information about all data fields. For Example: Student id: 9000123, name: Khaled Haddad, Courses Enrolled: CSCI250, CSCI250L, CSC200, NUTR 100. B. The UndergradStudent class inherits from the class Student. The code is below: public class UndergradStudent extends Student private int nbofCreditsEarned; public UndergraduateStudent (int i, String n, int nb) { super(i,n); nbofCreditsEarned = nb; public int getNbofCreditsEarned() { return nbofCreditsEarned; } public void setNbofCreditsEarned (int nb) { nbofCreditsEarned = nb; } public String toString() { return super.toString() +" Number of Credits Earned: +nbofCreditsEarned+" credits."; C. The GradStudent class inherits from the class Student. The code is below: public class GradStudent extends Student{ private boolean foundInternship; public GraduateStudent (int i, String n, boolean f) { super(i,n); foundInternship = f; } public boolean getFoundInternship () { return foundInternship; } public void setFoundInternship (boolean f) { foundInternship = f; ) public String toString() { String s = super.toString(); if (found Internship) return st" The student has found an internship."; else return st" The student has not found an internship."; } } Question 2 [20 points] Write a client class (application) in which you: a) Create 5 students, 3 UndergradStudent and 2 GradStudent objects using values assigned by the programmer. Do not ask the user to enter the values. Add some courses of your choice to the students you created b) Create an array (not an array list) and fill it with the 5 students c) Write a static method ArrayList getUndergradStudents (Student[] students, String course) that takes as parameter an array of students, and the name of a course. This method returns an array list containing all undergraduate students in the array students) enrolled in this course. d) In the main method, use the getUndergradStudents method to display the names of all the students enrolled in CSC1250

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions