File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
Lab Sheets/Lab Sheet 03/Lakshan/Exercise 4 Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ public class Student {
2+ private String name ;
3+ private String ditno ;
4+ private String address ;
5+
6+
7+ public Student () {
8+ this .name = null ;
9+ this .ditno = null ;
10+ this .address = null ;
11+ }
12+
13+ public Student (String name , String ditno , String address ) {
14+ this .name = name ;
15+ this .ditno = ditno ;
16+ this .address = address ;
17+ }
18+ public void setName (String name ) {
19+ this .name = name ;
20+ }
21+ public void setDitno (String ditno ) {
22+ this .ditno = ditno ;
23+ }
24+ public void setAddress (String address ) {
25+ this .address = address ;
26+ }
27+ public String getName () {
28+ return this .name ;
29+ }
30+ public String getDitno () {
31+ return this .ditno ;
32+ }
33+ public String getAddress () {
34+ return this .address ;
35+ }
36+ public String getDetails () {
37+ return "I am a Student.\n My name is " + this .name + "\n I am from " + this .address + "\n My dit no is " + this .ditno ;
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ public class Test {
2+ public static void main (String [] args ) {
3+ Student s1 = new Student ("Pasindu" ,"IT20123456" ,"Galle" );
4+
5+ System .out .println (s1 .getDetails ());
6+ }
7+ }
You can’t perform that action at this time.
0 commit comments