Student:
BCIS 3680 Assignment 2 Grade Sheet
Points
Grades
Course Class (10.5)
Instance variables and their getters and setters
Variable declared with private access modifier
Variable declared with required data types
Setter and getter methods follow correct naming convention
Setter method parameter list is as required
Getter method retrieves variable values correctly
Constructor
Method header is correct
Parameter list has the parameters as required
Initializes variables as instructed
1.5
1.5
1
1.5
1.5
1
1.5
1
Registration Class (8.5)
Instance variables
Variable declared with private access modifier
Variable declared with required data types
Constructor
Method header is correct
Parameter list has the parameters as required
Initializes variables as instructed
toString()
Returns a String
Calls proper getter method in Student object to read student name
Calls proper getter method in Course object to read course number
Concatenates room number properly
1.5
1.5
1
1.5
1
0.5
0.5
0.5
0.5
Driver Class (3)
main() method
Create Student object properly
Create Course object properly
Create Registration object properly
Generates correct output
Calls toString() in the Registration object
JOptionPane method displays dialog correctly
0.5
0.5
0.5
0.5
1
Other (3)
Text files of source code, screenshot
3
Hard Coding
Any hard coding (5 points deduction per occurrence)
Total
-5
25
-
BCIS 3680 Enterprise Programming
Instructor: Dr. Andy Wu
Assignment 2
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 be offered at a particular location. 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 each based
on 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 and 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
courseNum
courseTitle
hours
Data Type
String
String
int
Use
Course number
Course title
Number of credit hours
(a) Write getter and setter methods for courseNum and hours. For instance variables without
these methods, some IDEs (e.g., NetBeans) may display a warning message; disregard the
message.
BCIS 3680 Enterprise Programming
Assignment 1 p. 1
(b) Write a full initialization constructor that requires three parameters – one for each of three
instance variables – and assigns each parameter to its respective instance variable.
5. Create a Registration class and 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
student
course
room
Data Type
Student
Course
String
Use
A Student object for student enrolled in the course
A Course object for the course in which the student is enrolled
Room where course is offered
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 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. It should return a String that contains the following text:
is registered in at .
The bracketed parts are place holders, which should be replaced by real values in run time,
e.g.,
Anthony Castle is registered in BCIS3680 at BLB155.
For an example of toString()method, see the Building.java code sample. In that example, the
method reads instance variables within the class. In the case of Registration, the student name
and course number aren’t instance variables. However, it does contain a Student object and a
Course object as instance variables. You can assess student name and course number by calling the
proper getter methods in those objects.
6. Now, it’s time to piece everything together. Create a Driver class. In this class, create the main()
method, which does the following:
(a) Create a Student object. Call the full-initialization constructor by passing four arguments:
student ID, name, gender, and GPA.
(b) Create a Course object. Call the full-initialization constructor you built in Step 4 by passing
three arguments: course number, course title, and number of credit hours.
(c) Create a Registration object. Call the full-initialization constructor you built in Step 5 by
passing three arguments: the Student object you created in (a), the Course object you
created in (b), and a string containing the room number.
(d) Call the toString() method in the Registration object you created in (c). Call the
JOptionPane.showMessageDialog() method to display the return value of toString().
For example:
BCIS 3680 Enterprise Programming
Assignment 1 p. 2
7. Take a screenshot of the dialog box. Do NOT use your cell phone or camera to take it. Doing so
will cause point deduction. Instead, use the Snipping Tool in Windows to take the screenshot.
8. In Notepad++, create a text file Course.txt. Do NOT save it with .java extension. Make it a pure
text file with the .txt file extension.
9. In your IDE, copy the entire content of the finalized version of your Course.java. Paste it into
Course.txt and save. Note that you will want to update this text file if you make changes in
Course.java later, as you may be graded based on this file.
10. Repeat Steps 8 and 9 for Registration.java and Driver.java to create Registration.txt
and Driver.txt.
11. Zip the entire project folder into a compressed file by the name 3680-HW2-YourLastNameYourFirstName with the .zip, .rar, or .7z file extension. Do NOT include the three text files you
created in Steps 8 through 10 in the zip file.
Submission
Due Date: 11:59 PM on Saturday, September 26, 2020
Submission Requirements:
No hard copy is required.
Log into Canvas.
Locate the submission link for Assignment 2.
Attach the following files:
The compressed file containing your entire project folder.
Course.txt, Registration.txt and Driver.txt (outside of the zip file).
Screenshot file showing the result of code execution.
Failure to comply with these requirements will cause point deduction.
BCIS 3680 Enterprise Programming
Assignment 1 p. 3
Purchase answer to see full
attachment