Question: This is the student. java file down below /* Demo for: Classes Student.java This class defines a simple template for student objects To test it,

 This is the student. java file down below /* Demo for:Classes Student.java This class defines a simple template for student objects Totest it, create and structure proper folders for the bcis3680.demo.students package and

This is the student. java file down below

/* Demo for: Classes Student.java This class defines a simple template for student objects To test it, create and structure proper folders for the bcis3680.demo.students package and save this class to it. Alternatively, you may create you own package for testing and modify the package statement below to fit it. */ package bcis3680.demo.students;

public class Student { //***** Static Variable *****// static int studentCount;

//***** Instance Variables *****// private String untId; private String name; private char gender; private float gpa;

// ***** Constructor *****// // It doesn't make much sense to accept the default initial // values for these instance variables because each student // would have the name "null", ID "null" and is of the ' ' // gender. Therefore, a non-default constructor method is // created below, instead of using the default constructor // that Java runs implicitly for classes without an explicitly // created constructor method. public Student(String i, String n, char g, float gpa) { // Initializes instance variables of the new object untId = i; name = n; gender = g; this.gpa = gpa; // Add 1 to the static variable for object count studentCount++; }

// Like regular methods, a constructor method can be overloaded. // If warranted by software specs, we can create multiple version of the // constructor method. Below, we create a version that emulates the // "default" or implicit constructor that Java will run if no construtor // method is defined. Note that a default constructor automatically // created by Java won't increment the static variable. // As an aside, if a constructor is created, Java will // assume that we want to be control and will not run the "default" // constructor any more. public Student() { // No instance variable are initialized. // However, we still add 1 to the static varible for object count // because this contructor still does create an object, albeit an // "empty" one. studentCount++; }

// Another version of the constructor. This version only initializes the ID // and name. A realistic business scenario may be that some demographic data // of the customers are optional. So it may be that the only mandatory fields // of input are ID and name. In this case, we only initialize ID and name. public Student(String i, String n) { // Initializes only two of the four instance variables. untId = i; name = n; // Add 1 to the static variable for object count studentCount++; }

// ***** Setters and Getters *****//

// For UNT ID // public void setUNTID(String id) { untId = id; }

public String getUNTID() { return untId; }

// For Name // public void setName(String name) { this.name = name; }

public String getName() { return name; }

// For Gender // public void setGender(char gender) { this.gender = gender; }

public char getGender() { return gender; }

// For Age // public void setGPA(float gpa) { this.gpa = gpa; }

public float getGPA() { return gpa; }

// ***** Static Methods *****// // This is for illustration only. Since the object count is incremented in // in the contructors, there are rare, if at any, cases this would be really // needed to run. static void addToCount() { studentCount++; }

static int readStudentCount() { return studentCount; }

// ***** Instance Method *****// public void describeSelf() { String msg = "================================ "; msg += "Generated in Student Class "; msg += untId + "\t" + name + "\t" + gpa + " "; msg += "================================";

System.out.println(msg); } }

An advantage of object-oriented programming (OOP) over procedural languages is its ability to "emulate real world entities as objects. An OOP program can then implement the business logic of the application by programmatically setting up the objects to interact in ways they would in reality. In this assignment, we will create a few objects and use them to emulate a simple activity - registering a student in a course. To do this, we will instantiate a Student object using the class file I have already created and uploaded to Canvas as code sample. We will then create a course class and a Registration class and instantiate one object based on each of them. Finally, we will write a simple Driver class that ties everything together. In this and future assignments, we want to follow the encapsulation principle. When we create new instance variables in existing or new class files, we will declare them as private. However, you only need to write their related getter and setter methods when instructed to do so. Similarly, create constructors only when instructed. Bear in mind, though, when writing production programs, you'd want to flesh out a class fully by writing getter and setter methods for all instance variables and by building a set of overloaded constructors. 1. In your IDE, create a new project for Assignment 2. 2. In the project, create a package by the name your_lastname.your_firstname (replace with your real names). We will save all class source files in the folder for this package (i.e., your_project_folder\src\your_lastname your firstname). 3. Download the source code files of student.java into the package folder (this is the version with only four instance variables - ID, name, gender, and GPA). Add/modify its package statement to make it part of the your_lastname.your_firstname package. 4. Create a Course class. At the top of the source code, add lines of comment to show your name and date of writing the code. Then, make it part of the your_lastname your_firstname package using a proper package statement. This class should contain four instance variables as follows: Use Variable courseNum courseTitle Data Type String String String int Course number Course title Instructor name Number of credit hours instructor hours (a) Write getter and setter methods for courseNum and instructor. For instance variables without these methods NetBeans may display a warning message; disregard the message. (b) Write a full initialization constructor that requires four parameters - one for each of the four instance variables - and assigns each parameter to its respective instance variable. 5. Create a Registration class. At the top of the source code, add lines of comment to show your name and date of writing the code. Then, make it part of the your_lastname.your_firstname package using a proper package statement. This class should contain three instance variables as follows: Variable Data Type student Student course Course semester String Use A Student object for student enrolled in the course A Course object for the course in which the student is enrolled Semester during which the student is registered in the course The first two instance variables are reference types (note the use of upper and lower cases in naming). (a) Write a full initialization constructor that requires three parameters - one for each of the three instance variables, the first two being of the types Student and Course. Assigns each parameter to its respective instance variable. (b) Write a toString() method. The header of this method is public String toString(). The method return a String that contains the following text: is registered in taught by in is registered in taught by in

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!