File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
Lab Sheets/Lab Sheet 03/Lakshan/Exercise 3 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+ }
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+ s1 .setName ("Lakshan" );
6+ s1 .setDitno ("IT20657567" );
7+ s1 .setAddress ("Colombo" );
8+ System .out .println ("Name: " + s1 .getName ()+ "\n Ditno: " + s1 .getDitno () + "\n Address: " + s1 .getAddress ());
9+ }
10+ }
You can’t perform that action at this time.
0 commit comments