Design a Java class called U9D1CourseClass that has the following attributes: *c
ID: 3725461 • Letter: D
Question
Design a Java class called U9D1CourseClass that has the following attributes:
*code- a string field to store the course code (IT1006)
*credit hours- an int field to store the credit hours of the course (6)
Draw a UML class diagram for the course class. Then implement your design of the Course class into Java.
Explain how you completed this and any issues you faced and how you solved them.
This is a sample output of the JAVA code
This is what the UML diagram should look like
26 2.7 62) ued 1 corsedass.U801_courseClass > Output-U801-CourseClass (run) × main > zun: [Code:] [Code: IT10061 [Code : IT99991 >| [Credit Hours:0] [Credit Hours: 61 [Credit Hours: 91 | BUILD SUCCESSFUL (total time : 0 seconds)Explanation / Answer
Please find my answer.
UML diagram is already given.
Please let me know in case of any issue.
public class U9D1CourseClass {
private String courseID;
private int creditHrs;
public U9D1CourseClass() {
courseID = "";
creditHrs = 0;
}
public String getCourseID() {
return courseID;
}
public int getCreditHrs() {
return creditHrs;
}
public void setCourseID(String courseID) {
this.courseID = courseID;
}
public void setCreditHrs(int creditHrs) {
this.creditHrs = creditHrs;
}
@Override
public String toString() {
return "[code:"+courseID+"] [Credit Hours: "+creditHrs+"]";
}
public static void main(String[] args) {
U9D1CourseClass o1 = new U9D1CourseClass();
System.out.println(o1);
o1.setCreditHrs(6);
o1.setCourseID("IT1006");
System.out.println(o1);
o1.setCreditHrs(9);
o1.setCourseID("IT9999");
System.out.println(o1);
}
}
/*
Sample run:
[code:] [Credit Hours: 0]
[code:IT1006] [Credit Hours: 6]
[code:IT9999] [Credit Hours: 9]
*/