-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourse.java
More file actions
125 lines (117 loc) · 2.95 KB
/
Copy pathCourse.java
File metadata and controls
125 lines (117 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* This class represents an individual Course object
* @author Enock Niyonkuru
* @version 1.0 May 1,2021
*/
public class Course{
// fields
String name;
String title;
int students;
int votes;
//defualt contrsuctor
public Course(){
}
/**
* parameterized constructor
* @param name a string holding the name of the course
* @param title an string holding the title of the course
* @param students a int holding the number of students who took the course
* @param votes and int holding the number of votes of each course
*
**/
public Course(String name, String title, int students, int votes){
this.name = name;
this.title = title;
this.students = students;
this.votes = votes;
}
/**
* get method for product name
* @return name String the course's Name
* Time Complexity: O(1)
**/
public String getName(){
return name;
}
/**
* get method for course title
* @return title String the course's title
* Time Complexity: O(1)
**/
public String getTitle(){
return title;
}
/**
* get method for course number of students
* @return students int the course's number of students
* Time Complexity: O(1)
**/
public int getStudents(){
return students;
}
/**
* get method for course number of votes
* @return int votes the course's votes
* Time Complexity: O(1)
**/
public int getVotes(){
return votes;
}
/**
* set method for course name
* @param name String the course's Name
* Time Complexity: O(1)
**/
public void setName(String name){
this.name = name;
}
/**
* set method for course title
* @param title String the course's title
* Time Complexity: O(1)
**/
public void setTitle(String title){
this.title = title;
}
/**
* set method for course number of students
* @param students int the course's number of students
* Time Complexity: O(1)
**/
public void setStudents(int students){
this.students = students;
}
/**
* set method for course number of votes
* @param votes int the course's number of votes
* Time Complexity: O(1)
**/
public void setVotes(int votes){
this.votes = votes;
}
/**
* calculate and return the recommendation score, the percentage of students who recommended the Course
* @return double recommendation score
* Time Complexity: O(1)
**/
public double getScore(){
return((votes *100)/students);
}
/**
* String representation of a full course description
* @return String description of the whole course
* Time Complexity: O(1)
**/
public String description(){
return (name + ": " + title + " has been taken by " + students + " students and has a " + getScore() + "% recommendation score. ");
}
/**
* string representation toString of the course name and the recommendation score
* @return String representaiton of course's name and recommendation of a course
* Time Complexity: O(1)
**/
public String toString(){
return(name + ": " + getScore() + "%");
}
}