Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Based on the following description, write a Java class. He courses in Anglestate are represented by Course objects. Each Course has a name of the

Based on the following description, write a Java class. He courses in Anglestate are represented by Course objects. Each Course has a name of the course, the number of students registered for the course, and an array of string that contains the name of each student (you can set the array size to 100). Thus, the class Course should contain three instance variables: String courseName, String[] students = new String[100], and int numberOfStudents. A Course is created by passing a course name as shown below. When a new Course is created, the number of students is initialized to 0. In this case, the course name is ICS 241-01 Object Programming.

>Course cs1 = new Course(ICS 241-01 Object Programming);

The class must be designed in such a way that it returns a reasonable representation of the Course object as the following example shows (the registered number is just one of possible values).

>System.out.println(cs1);

Course ICS 241-01 Object Programming. Number of students registered 10.

The class must have a method name addStudent, which is called when a student registers the course. The method accepts student name as a parameter. The number of students registered must then be incremented by 1. The method does not return anything. The following code registers a new student named Michael to the newly created course cs1.

>cs1.addStudent(Michael);

>System.out.println(cs1);

Course ICS 241-01 Object Programming. Number of students registered 11.

The class has a method named getNumberOfStudents, which returns the number of students registered for the course. The following code is an example of using it.

>System.out.println(cs1.getNumberOfStudent());

11

The class aslso has a method name getCourseName, which returns the name of the course. The following code is an example of using it.

>System.out.println(cs1.getCourseName());

ICS 241-01 Object Programming

WRITE THE JAVA CLASS FOR THE COURSE OBJECT IN THE SPACE BELOW:

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_2

Step: 3

blur-text-image_3

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

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions

Question

5. Recognize your ability to repair and let go of painful conflict

Answered: 1 week ago