Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is a two-part assignment. Don't miss Homework 7!
- This part of the assignment involves writing a class and some tests. The second part of the assignment involves accessing a mySQL database to get data for the table.
- You are to write a class that represents one section of a course at Missouri Western.
- Creating the project in Maven Create from the archetype org.apache.maven.archteypes:maven-archetype-quickstart
- After the project starts, be sure to enable auto-imports in the lower right-hand corner of Intellij.
- The Section class
- The Section class should have the following data members and implement the class Comparable<Section>:
- discipline: String (Such as ACT, CSC, MAT, or PHY
- number: String (such as "184" "254" or "110E"
- crn: (What data type do you think it should be?)
- title: String
- Instructor: String
- maximumEnrollment: integer
- seatsAvailable: integer
- Constructors
- A constructor that takes all fields
- A constructor that takes all fields, except that instead of a discipline and course number, it takes a combined courseId such as "CSC184" Your constructor would need to split the courseId.
- Setters
- All fields should have setters. These can be the trivial setters, except that the setDiscipline setter must make sure the discipline is all upper case.
- Getters
- All fields should have getters.
- There should be a pseudo-getter for getCourseId(). The courseID is the discipline concatinated by the course number with no space between.
- getEnrolled() calculates the number of students enrolled based on the seats available and the maximum enrollment.
- toString
- toString must produce output like the following:
- Open RDG095 (10821) "Reading Skills Improvement" 10 enrolled (Max: 22) Instructor: Ancerson, C
- The leading Open indicates that the seatsAvailble > 0. It would say FULL if seatsAvailable <= 0.
- compareTo
- CompareTo uses the getCourseId value. If there is a tie, the tie is broken on the CRN.
- Other Methods
- isOpen() returns a boolean.
- Return true if the seats available > 0
- Return false if the seats available < 0
- Tests
- Frankly, testing will be not very complete. You only need three tests per method. The main idea is to get comfortable with creating tests.
- Create at least three static objects at the class level that can be used for testing.
- Test all methods that return a value. This includes toString().
- The main() method
- The main method should create two objects using each of the two objects.
- Print the two objects created using the toString() method.
Advertisement
Add Comment
Please, Sign In to add comment