-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
70 lines (57 loc) · 1.32 KB
/
Copy pathMain.java
File metadata and controls
70 lines (57 loc) · 1.32 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
package oop;
class Student {
Integer id;
String name;
String department;
Student() {
id = null;
name = null;
department = null;
}
Student(Integer id, String name, String department) {
this.name = name;
this.id = id;
this.department = department;
}
public void display() {
System.out.println(id + " " + name + " " + department + "\n");
}
}
class Course {
private Integer courseId;
private String courseName;
private Integer credits;
public void setCourseId(Integer courseId) {
this.courseId = courseId;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public void setCredits(Integer credits) {
this.credits = credits;
}
public Integer getCourseId() {
return courseId;
}
public String getCourseName() {
return courseName;
}
public Integer getCredits() {
return credits;
}
}
public class Main {
public static void main(String[] args) {
Student s1 = new Student();
Student s2 = new Student(45, "Atharv Shukla", "CSE(AI&ML)");
s1.display();
s2.display();
Course c1 = new Course();
c1.setCourseId(7);
c1.setCourseName("B.tech");
c1.setCredits(10);
System.out.println(c1.getCourseId());
System.out.println(c1.getCourseName());
System.out.println(c1.getCredits());
}
}