Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a class called GtStudent that has the following instance data: name: The name of the student. Should be represented as a constant

 

1. Create a class called GtStudent that has the following instance data: name: The name of the student. Should be represented as a constant String value since a student's name should not change after being set. gtid: This should be an int that represents the student's GT Id (i.e. 903xxxx). classYear: This should be an int value between [1, 4] that represents the student's year in college. a. b. . gpa: This should be a double between [0.0, 4.0] that represents the student's grade point average. e. diningDollar: Should be a double that represents the student's current amount of dining dollars d. f. buzzfund: Should be a double that represents the student's current amount of buzzfunds All of the above variable should have correct visibility to enforce the principle of encapsulation. Gtstudent should have the following constructors: It must be possible to create a student with the following combinations of initial data provided as g. 2. a. parameters on construction i. name, gtid, classYear, gpa, diningDollar, buzzfund ii. name, gtid, classYear iii. name, diningDollar, buzzfund iv. name v. GtStudent, name: this constructor should create a GtStudent that has the same instance data as the passed in GtStudent except for name A name b. the student must always be provided on construction . The default value for gtid must be -1 when not provided on construction or if the provided parameter is invalid (not a 903xxxxxx number) Page < 2 of 4 ZOOM + d. The default value for classYear must be 1 when not provided on construction or if the provided parameter is invalid (not [1,4]) e. The default value for diningDollar and buzzfund must both be 0.0 when not provided on construction or if the provided parameter is negative. f. The default gpa must be 4.0 when not provided on construction or if the provided parameter is invalid ([1.0, 4.0]) Note: Constructor chaining MUST be used where possible. g. 3. GtStudent should have the following instance methods: Below you are given the method signatures and specification for the Student class. Make sure these are instance methods and the signatures match exactly. a. purchaseMeal (double cost): i. Reports whether there are enough funds to purchase the meal and updates the student's funds accordingly. The cost should be deducted from the object's diningDollar first and from buzzfund only when the dining dollars are no longer available. If a student has 5.0 dining dollars and 5.0 buzzfunds, and attempts to purchase a meal costing 7.0, they should end up with 0 dining dollars and 3.0 buzzfunds. ii. Prints out when the cost is successfully deducted by the appropriate fund variable: "(name} has successfully purchased the meal" 1. There is a newline character at the end of the String 2. {name} should be the name of the student iii. If there are not enough funds to purchase the meal, prints out: "{name} does not have enough funds to purchase the meal" 1. There is a newline character at the end of the String {name} should be the name of the student b. addDiningDollars (double diningDollar) : Adds the passed in amount of diningDollar to the instance field diningDollar uble buzzfund) : addBuzzfund ( Adds the passed in amount of buzzfund to the instance field buzzfund d. increaseClassYear (): Increments the current classYear of the Student object by 1, if the classYear is 4, then it should remain as 4 NOTE THE FOLLOWING: You must use the exact method signatures provided above If we did not explicitly specify what a method should return you can assume it returns nothing Page < of 4 ZOOM If we did not explicitly specify what a method should return you can assume it returns nothing Creating CourseSection 1. Create a class called Coursesection that has the following instance data: a. subject: a String that represents the course subject (ex. CS) b. courseNumber: an int that represents the course number (ex. 1331) C. roster: an array of GtStudents that are enrolled in the course d. numstudents: a long that represents the number of students in the course 2. Constructor that takes in parameters for all of the above instance data 3. CourseSection must contain a static int constant field MAX_ENROLL that is set to 400 4. CourseSection must contain a static int field numsections that maintains how many CourseSections have been created. 5. CourseSection must have the following instance methods: a. addstudent (Gtstudent student): adds the student to the roster if the roster hasn't reached capacity. This should also increment the number of students enrolled in the course. NOTE THE FOLLOWING: Sample Test Cases There will be no test cases provided, try creating GtStudent Objects and test your code. It is highly recommended that you create a driver class to test your code so you can ensure encapsulation. (a driver class is just a regular class declared as public class Driver, and doesn't have any special powers) Chockstvle

Step by Step Solution

3.29 Rating (158 Votes )

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

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions

Question

What is meant by insider trading? insider? tippee?

Answered: 1 week ago

Question

1. Why are hallucinations considered a positive symptom?

Answered: 1 week ago