COSC102 HW1-version1-1
COSC102 HW1-version1-1
Overview:
In this first part of your project, you will get experience with basic programming concepts by
creating a small part of a Learning Management System (LMS). This system is what schools and
universities use to manage courses, teachers, and students. You will writw Java code to represent
courses and students.
Creating Classes and Objects: You'll learn how to design templates for courses and students,
using classes, and then create instances of these classes, which are objects. This is like making a
blueprint and then building something based on that blueprint.
Flow-Control: You'll use if-statements and/or switch-statements to make decisions in your code.
Using Basic Mathematical Functions: You'll calculate the average score of students in a course.
Methods: You'll write functions within your classes to perform actions, like assigning a score.
Classes to Implement:
1. Course Class
Attributes:
- courseName: The name of the course (e.g., "Object Oriented Programming").
- courseID: The unique identifier of the course (e.g., "COSC102").
- instructor: The name of the instructor teaching the course.
- add at least two more attributes as you see fit.
Methods:
- Create the accessor and mutator methods for all your data fields. When called, the
mutator methods should print a message indicating the change. For example, the
mutator for the instructor field would print "The instructor with name
<instructor_name> has been assigned to teach this course” (Note that <
instructor_name > should be the name of the instructor which is passed as argument
to this method).
- Add a static method named calculateAverageScore, which takes three scores as
arguments, and returns their average.
- Add a method named printCourseDetails which prints the course attributes in a
formatted string. For example,
o Course code: COSC102
o Course name: Object-Oriented Programming
o Course instructor: Dr. Fatema Akbar
2. Student Class
Attributes:
- studentName: The full name of the student (e.g., Isaac Newton).
- studentId: The unique identifier of the student (e.g., A01029).
- year: An integer representing the student’s year (1, 2, 3 or 4).
- Add 2-3 additional data fields as you see appropriate (e.g. college, major, date enrolled,
advisor, etc.)
Methods:
- Create the accessor and mutator methods for all your data fields. When called, the
mutator methods should print a message indicating the change. For example, the student
name mutator would print "The student's name has been updated to <new_name>." (Note
that <new_name> should be replaced with the name of the argument passed to this
method).
- Create a method named advanceToNexYear which increments the student’s year by one.
- Create a method named yearString which prints the student's year in words. Use a switch
statement to print “Freshman” for year 1, “Sophomore” for year 2, “Junior” for year 3,
“Senior” for year 4, and “unknown” for any other year.
Task 1: Design and Model
For this task, you will create a Unified Modeling Language (UML) diagram for the classes you
plan to create. UML diagrams are tools that help developers visualize a program and outline its
classes, attributes, methods, and the relationships between classes. For this exercise, you'll focus
on a Class Diagram, which is a type of UML diagram.
For each class, list its attributes and methods. Include visibility indicators before each attribute
and method to indicate their access level. For instance, +studentName: String indicates a public
attribute named studentName of type String.
Remember to include data types for attributes and return types for methods.
Task 2: Implementation
1. Create a Java class called Student. The Student class should have the attributes and
methods as described in the Student Class.
2. Create a Java class called Course. The Course class should have the attributes and
methods as described in the Course Class.
Now that you've designed classes and their methods, it's time to test your classes. In this task,
you will create instances of your Course and Student classes and use these instances to test the
functionality of your code.
Submission Guidelines:
Submit your three Java files (Course class, Student class and TestClass) and your UML diagram
in a word document in a zip file on Canvas. Email submissions are not accepted.
Start the submission process early to avoid delays and technical issues.
Grading rubric:
Correct UML(6 pt, CLO B1)
Coding logic, quality and design (e.g. following assignment requirements, avoiding unnecessary
repetition of code, appropriate data types, correct implementation and use of classes) (10 pt,
CLO A2, B2)
Code follows naming conventions for classes, methods and variables (4 pt, CLO A2, B2)