辅导案例-EECS 2030-Assignment 2

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
EECS 2030 Assignment 2
Fall 2020
Deadline: Tuesday Dec 6th, 2020 11:59pm
In this assignment, we are going to assess your ability to use object-oriented programming features.
This includes
❖ The ability to read an UML and implement the code accordingly.
❖ The ability to create an object.
❖ The ability to use an object’s attributes and methods.
❖ The ability to implement the relationships between objects.
❖ The ability to make use of object-oriented programming features such as encapsulation,
static factory method, overridden methods, static and non-static components of an object,
and exception handling.
❖ The ability to test your code.
❖ The ability to document your code.

While this assignment algorithmically is far less challenging than the first assignment, it relies heavily
on object-oriented principles.


Setting up the environment:
❖ Download the attached .jar file.
❖ Create a java project in eclipse. It does not matter what is the name of the project.
❖ Right click on the name of the project and select ‘import’.
❖ From ‘General’ choose ‘Archive file’ and click next.
❖ Click ‘Browse’ to select the a2.jar file that you have already downloaded.
❖ Click ‘Finish’.
❖ If all the steps were done correctly you should see ‘Assignment2’ under ‘src’. In case
‘Assignment2’ was not under ‘src’, drag and drop it to the ‘src’ folder.

Before you start, we, the instructors, would like to remind you that this assignment is different from
the labs that you have done, as it is accounted as an exam that you take home. This means you cannot
discuss your solution with anybody including your peers and you should not get help from anybody
to solve this problem. You should not post a question about this exam in public (i.e. in Piazza). So
please have a look at the statement at the top of Transcript.java before you start doing the
assignment. When you are finished you need to sign the statement by writing your information in the
gap provided. Please be aware that your assignment WILL NOT be marked if you do not sign the
declaration. Also, you should be informed that your assignment’s grade will be valid, only if our
plagiarism detection tool identifies the submission as original.

Problem Description:
In this assignment, you are going to generate a transcript for students. Information about the
students, the courses that they have taken, and the grades that they have received for different
activities of a course are stored in a text file. Your program reads the text file and generates a
transcript and write it to another text file.

First let us have a look at the format of the text file. The text file contains several rows, each dedicated
to one course for one student. In each line you see:

Course code, course credit, student number, [P|E] a number that shows
the weight of the assessment (a number that shows the grade received
for this assessment), …., student name.

In this format P stands for practical, which is associated to any types of assessment such as lab activity,
exercises, homework, worksheets and so on. E stands for Exam.

For example, this line
EECS2030,3,1000,P10(90),P10(80),P30(60),E15(60),E15(44),E20(80),John
explains that John, whose student number is 1000 has taken EECS2030, which is a three credits course. This
course has three practical activities, which worth 10, 10 and 30 percent of the total mark, respectively. Also,
this course has three exams, which worth 15, 15 and 20 percent of the final mark, respectively. Please note that
the total of the weights must always be 100. The numbers that are in parenthesis shows the grade that John
has received out of 100 for each assessment.

Please have a look at the text file (input.txt) that came with the starter code, to better understand the format
of the file.

Task 1:
In this assignment, we are not going to tell you what to do step by step. Instead we ask you to implement our
design that can be seen in the UML diagram below. In this diagram, you see all the classes, their attributes,
methods, and relationship with each other, that you need to develop.



Please note that
❖ you can find the explanation about each class and its methods in the glossary at the final page of this
document.
❖ not all the required methods can be seen in this diagram (and also in the glossary). Specifically
speaking, I have removed all the accessors and mutators to let you decide, which class requires one.
❖ All the methods that are seen in the UML must be implemented.
❖ In case you needed to add helper methods to make your code more readable, you are welcome to do
so. However, make sure that your helper methods are defined private.
❖ You should not add any attributes to the classes.
❖ You should not change any method signature.
❖ readFile() and the constructor of Transcript have already been implemented for you.
❖ Encapsulation should be applied to all the classes.
❖ Two students do not have the same student ID, and two different courses do not have the
same code. This means you do not need to verify the correctness of the text file for these
cases.
❖ courseTaken and finalGrades are parallel arrays. Two (or more) arrays are called
parallel if A) they have the same number of elements, B) items in the same indexes are
related. In our case, finalGrade at index i, shows the grade that the student received for
the courseTaken at index i.
❖ weightedGPA and addGrade should round the grade to one decimal place.
❖ No test case is provided. It is your job to test each method and the whole program.
❖ You can import any java package that you require.
❖ No Documentation is provided. You are required to document the code completely. I have
only provided some documentation for some of the methods, whose functionality were less
obvious in the glossary.
❖ To compute the GPA, the following table should help you. GPA = Average (grade
point x course credit)
Grade Point Grade
9 90-100
8 80-89.99
7 75-79.99
6 70-74.99
5 65-69.99
4 60-64.99
3 55-59.99
2 50-54.99
1 47-49.99
0 Otherwise

Output:
The output should follow the format that is explained below.


As you see in the first line, first comes the name of the student followed by a tab (i.e. “\t”) followed by the
student number.
Next line contains 20 dashes.
Then in each line comes the course code followed by a tab and the grade that the student achieved for it.
Next line contains 20 dashes.
Next line the word GPA: is followed by the GPA that is rounded by one decimal place. There is a space between
“GPA:” and the value of the GPA.
This pattern is continued for the rest of the students in the file.

Task 2: Exception Handling
It is time to handle the exceptions. It is possible that the total weight of the assessment in a row of the file does
not add up to 100. Also, it is possible that the total grade of a student is more than 100. These two cases are
wrong and therefore, an exception should be thrown. You should write your own exception that is called
InvalidTotalException, that can be used for both the flawed situations.
This exception should be handled in the method called addGrade.


What to Submit:
you only submit one file, which is the completed Transcript.java file. All the classes should be in this
file.

How to Submit:
❖ Submit your solution via https://webapp.eecs.yorku.ca/submit, choose 2030 for the course
and a2 for this assignment.

Marking Scheme:
Please note that the submitted code should be compiler-error free. If the code has compiler error,
no mark will be awarded for code execution.
❖ 25% on the correctness of buildStudentArry()
❖ 30% on the correct implementation of class Student.
o 5%: weightedGPA()
o 5% : addGrade()
o 5%: addCours()
o 5%: encapsulation
o 5%: correctness of composition
o 5%: exception handling
❖ 15% on the correct implementation of class Course.
o 5%: equals()
o 5%: encapsulation
o 5%: correctness of composition
❖ 10% on the correct implementation of class Assessment.
o 5%: encapsulation
o 5%: getInstance()
❖ 20% on documentation

You will receive zero if you do not sign the declaration of academic honesty at the top of your code.








Glossary:
The list of all classes, methods and instance variables are written here for two purposes. First, to
make sure you do not lose any mark because of a typo. Second, the purpose of each component is
described here. This list is sorted alphabetically.
❖ addCourse: get a course object as an input and add it to courseTaken.
❖ addGrade: This method gets an array list of the grades and their weights, computes the true value
of the grade based on its weight and add it to finalGrade attribute. In case the sum of the weight was
not 100, or the sum of grade was greater 100, it throws InvalidTotalException, which is
an exception that should be defined by you.
❖ assignment: It is an attribute for the Course class.
❖ Assessment: it is a class name.
❖ buildStudentArray: This method creates and returns an ArrayList, whose element is
an object of class Student. The object at each element is created by aggregating ALL the
information, that is found for one student in the grade Arraylist of class Transcript. (i.e.
if the text file contains information about 9 students, then the array list will have 9 elements.
❖ code: It is an attribute for the Course class.
❖ Course: This is the class that defines a course.
❖ courseTaken: It is an attribute for the Student class.
❖ credit: It is an attribute for the Course class.
❖ equals: it is an overridden method for Object’s equals() method that returns true, if all the
instance variables of two objects have the same value.
❖ finalGrade: It is an attribute for the Student class.
❖ getInstance: This is a static factory method for class Assessment.
❖ grade: It is an attribute for the Transcript class.
❖ inputFile: It is an attribute for the Transcript class.
❖ InvalidTotalException: This is the exception that is thrown if the total weight of the
assessments does not add up to 100, or of the total grade of a student is more than 100.
❖ Name: It is an attribute for the Student class.
❖ outputFile: It is an attribute for the Transcript class.
❖ printTranscript: This is the method that prints the transcript to the given file (i.e.
outputFile attribute)
❖ readFile: It is a method that reads the input file and stores each line of the file in the
grade attribute of class Transcript.
❖ Student: It is a class that defines a student.
❖ studentID: It is an attribute for the Student class.
❖ Transcript: It is a class that reads a file containing the students’ information, and
generates a transcript for all the students.
❖ type: It is an attribute for the Assessment class.
❖ weight: It is an attribute for the Assessment class.
❖ weightedGPA:It is the method that computes the GPA.





欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468