Assignment_4 Solution

$30.00 $24.00

Design a class named Course. The class contains: Four private data fields [10 points] name (String) : The name of a course credit (int) : The credit hours of a course grade (String) : The grade of the students that a course can be open to, including “freshman”, “sophomore”, “junior”, “senior”. teacher(String) : The teacher…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Design a class named Course. The class contains:

  1. Four private data fields [10 points]

    • name (String) : The name of a course

    • credit (int) : The credit hours of a course

    • grade (String) : The grade of the students that a course can be open to, includingfreshman,sophomore,junior,senior.

    • teacher(String) : The teacher of a course

  1. Design two constructors: [10 points]

      1. A constructor with one parameter name.

      1. A constructor with four parameters including name, credit, grade and teacher.

  1. Design the getter and setter method for each private field of course. [10 points]

  1. Design a toString() method, which can return a String value of the course name. [10 points]

  2. Design a public method named getCourseLevel() to returnmajor course when the course grade isjunior andsenior, returncommon course when the course grade isfreshman andsophomore and returnnot valid query otherwise. [10 points]

  1. Design a public static method named getQualificationForCourse() with grade as the parameter. This method returnsYou are not qualified for the course when it is a major course with the inputfreshman and sophomore, or when it is a common course with the inputjunior andsenior; it also returnsYou are qualified for the course when it is a major course with the inputjunior andsenior, or when it is a common course with the inputfreshman andsophomore; it returnsnot valid query otherwise. [10 points]

  1. Design a public method named isWithLab() to returntrue when the credit hour is 3, returnfalse otherwise. [10 points]

Design a class named CourseTest. In this class, you should design a main method and also

  1. keep asking the user to create a course until he/she quits. [10 points]

  1. next, keep asking the user to obtain certain course information based on the index of the course in its data structure. In particular, given the course, you should be able to tell whether it is a major or common course, whether it comes with labs, and whether you are able to enroll in the

course based on your grade. Moreover, you should be able to tell all the courses given a credit hour and a teachers name.[10 points]

  1. at last, keep asking the user to obtain course information after removing certain course until he/she quits. [10 points]

One example overall program flow is as follows.

First, you should repeatedly ask userWould you like to create some courses: yes or no ?: ifyes, you should promptPlease input the course name: and so forth. In the following, we set three courses including {java programming, 3, freshman, tom ko}, {frontier seminar, 1, junior, yepang liu}, and {object oriented programming, junior, yuqun zhang}; ifno, this process is terminated.

Would you like to create some courses: yes or no ?

yes

Please input the course name:

java programming

Please input the course credit:

3

Please input the course grade:

freshman

Please input the course teacher:

tom ko

Would you like to create some courses: yes or no ?

yes

Please input the course name:

frontier seminar

Please input the course credit:

1

Please input the course grade:

junior

Please input the course teacher:

yepang liu

Would you like to create some courses: yes or no ?

yes

Please input the course name:

object oriented programming

Please input the course credit:

3

Please input the course grade:

junior

Please input the course teacher:

yuqun zhang

Would you like to create some courses: yes or no ?

no

Second, you should keep asking userWould you like to obtain course information: yes or no?: ifyes, you should prompt the total number of the current courses, such asThere are 3 courses in the system, please pick No. and wait for user to input the index of the courses he/she just input before, such as1 in the following text. Correspondingly, you should prompt the information of theNo.1 course. In our case, the course level is major course, it does not come with lab since its credit hours are 1. If you are a junior student, you are qualified for the course. In addition, you can also input a course credit, say3, to find out all the courses with 3 credit hours. In our case, they arejava programming andobject oriented programming. You can also input a teachers name, saytom ko, to find out all the course that are taught by Professor. Tom Ko. In our case, they arejava programming. Then this process is terminated by throwing the questionWould you like to obtain course information: yes or no? again. Ifno, the entire process is terminated.

Would you like to obtain course information: yes or no ?

yes

There are 3 courses in the system, please pick No.1

The course level is: major course

Is this course with lab? false

Please enter your grade:

junior

The result for your qualification to enroll in the course is: You are qualified for the course

Input a course credit:

3

The courses with 3 credits are [java programming, object oriented programming]

Input a teacher’s name:

tom ko

The courses taught by tom ko are [java programming] Would you like to obtain course information: yes or no ? no

Third, you should askWould you like to obtain course information after removing certain courses: yes or no?: ifyes, you should promptPlease pick the index of the course you want to remove. If the user responds with0 in our case, you should promptThe remaining courses are [frontier seminar, object oriented programming]. Then this process is terminated by throwing anotherWould you like to obtain course information after removing certain courses: yes or no?: ifno, the entire program is terminated.

Would you like to obtain course information after removing certain courses: yes

or no ?

Please pick the index of the course you want to remove:

0

The remaining courses are [frontier seminar, object oriented programming] Would you like to obtain course information after removing certain courses: yes or no ?

yes

Please pick the index of the course you want to remove:

0

The remaining courses are [object oriented programming]

Would you like to obtain course information after removing certain courses: yes or no ?

no

What to submit

  1. Please submit two.java files includingCourse.java and CourseTest.java , and make sure that those.java files have no package

information included.

    1. Course.java: It is for you to create and design.

    1. CourseTest.java: It is for you to create and design.

  1. The prompts, including the words and their sequential patterns, should be exactly the same as our example.

  1. It is your own jobs to take care of the corner cases. Some corner cases are listed as follows.

    1. bound check, e.g., you cannot always remove the created courses.

    1. Input validation, e.g., what if the input course grade is not one of freshman,sophomore,junior, andsenior.

    1. In fact,java programming is taught by three professors together. Think about how you would deal with the query about this fact.

    1. The system you design should be case-­‐insensitive, e.g., “zhang” and “Zhang”, “Yes” and “yes” are perceived as the same in your system.

e. …

We will have test cases for those corner cases when grading you.

  1. No Chinese characters are allowed to appear in your code.

  1. Please submit your assignment on the SAKAI site of your lab section. Marks will be deducted if you submit later than the deadline. If you submit your assignment within 24 hours after the deadline (grace period), your score will be half of the score you could get if the submission was made before the deadline. Assignments submitted after the grace period will not be graded (meaning you will get a zero for the assignment).

4

Assignment_4 Solution
$30.00 $24.00