-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomework6.java
More file actions
48 lines (42 loc) · 1.28 KB
/
Copy pathHomework6.java
File metadata and controls
48 lines (42 loc) · 1.28 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
public class Homework6 {
public static void main(String[]args){
OfflineCourse course1=new OfflineCourse("HAEA9201","Object Oriented Programming");
OnlineCourse course2=new OnlineCourse("HAFL0012","C Programming 1");
System.out.println(course1);
System.out.println(course2);
}
}
class Course{
protected String code;
protected String name;
public void course(String code, String name){
this.code=code;
this.name=name;
}
public String getCode(){
return code;
}
public String getName(){
return name;
}
}
class OnlineCourse extends Course{
public OnlineCourse(String code, String name){
this.code=code;
this.name=name;
}
@Override
public String toString() {
return "Code: "+code+", Name: "+name+", Type: Online";
}
}
class OfflineCourse extends Course{
public OfflineCourse(String code, String name){
this.code=code;
this.name=name;
}
@Override
public String toString() {
return "Code: "+code+", Name: "+name+", Type: Offline";
}
}