-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManagement.java
More file actions
88 lines (68 loc) · 1.81 KB
/
Copy pathManagement.java
File metadata and controls
88 lines (68 loc) · 1.81 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
package MangementSystem;
class Management {
public static void main(String[] args) {
Course a = new Course(1,"B.Tech",3);
Faculty f = new Faculty("A");
f.assignCourse(a);
Student s1 = new Student("A",1);
Student s2 = new Student("B",2);
Student s3 = new Student("C",3);
Student s4 = new Student("D",4);
s1.showProfile();
f.showProfile();
s1.enroll(a);
s2.enroll(a);
s3.enroll(a);
s4.enroll(a);
}
}
abstract class User{
abstract void showProfile();
}
interface Enrollable{
void enroll(Course course);
}
class Student extends User implements Enrollable {
String name;
int rollno;
Student(String name, int rollno) {
this.name = name;
this.rollno = rollno;
}
public void enroll(Course course) {
}
void showProfile() {
System.out.println("Student name is " + name + " and roll number is " + rollno);
}
}
class Faculty extends User{
String name;
Faculty(String name) {
this.name = name;
}
void showProfile() {
System.out.println("Faculty name is " + name);
}
void assignCourse(Course c) {
String cname = c.title;
System.out.println(name + " is assigned with " + cname);
}
}
class Admin extends User{
void showProfile() {
System.out.println("Admin profile");
}
}
class Course {
int courseCode;
String title;
int capacity;
Course(int courseCode, String title, int capacity) {
this.courseCode = courseCode;
this.title = title;
this.capacity = capacity;
if (capacity>2){
System.out.println("We can't enroll course as capacity exceeds 2 capacity");
}
}
}