Question
You will write a Java class to represent a class section like our very own SOC 300. This class has a number of data members
You will write a Java class to represent a class section like our very own SOC 300. This class has a number of data members (aka instance variables, aka properties aka attributes) which we all know so well from looking at class schedules on the school web site:
1. CRN, like 10059
2. Department code, like SOC
3. Course number, like 300
4. Instructional mode, like online, on-ground or hybrid
5. Meeting days (on-ground and hybrid only, otherwise N/A)
6. Meeting times (on-ground and hybrid only, otherwise N/A)
7. Capacity (maximum number of students who can enroll in it)
8. Enrollment (number of students actually enrolled in it)
9. Instructors ID number
The class representing a class section will have all of the attributes listed above along with getter and setter methods for each of them. It will also have a default constructor that takes no parameters. This constructor will assign (empty string) to String attributes, 0 to int attributes and 0.0 to double attributes, if any. The ClassSection class will also have a constructor that accepts a parameter for each attribute. Lastly, it will have a toString method that returns a String containing labels and values for all of the attributes. A sample of the String produced by toString() is shown below; notice that it uses new line characters to display parts of the String on different lines:
CRN : 10059
Department : SOC
Course number : 300
Instructional mode : Online
Meeting days : N/A
Meeting times : N/A
Capacity : 60
Enrollment : 60
Instructors ID : 122
After creating the Java file for class section, you need to create an application that uses it. We often call these applications driver programs. For our purposes, the driver program will create one instance of a class section object using its default constructor. Then it will use the 1 objects setter methods to assign values to its attributes. After doing this, the driver will use either println or printf to display the String returned by toString. Next, it will create a second instance of a class section object using the constructor that accepts values for all of its attributes. Again, it will it will use either println or printf to display the String returned by toString.
Provide your Java source code both the class section and the driver program.
As it states, I need both a class and a driverclass. I've tried a dozen different ways and can't get it to work on my own.
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