-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathch5.kt
87 lines (65 loc) · 1.44 KB
/
ch5.kt
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
/*** Constructor ***/
// Secondary Constructor
/*class People
{
//Properties
var nName:String
var nAge:Int
var gender: String = "Female"
constructor(name:String , age : Int)
{
println("Constructor Called ")
nName = name
nAge = age
}
//Member Function
fun disp()
{
println("The name: $nName")
println("The age: $nAge")
println("The gender: $gender")
}
}
fun main()
{
val nm = People("Vipin Kumar",21)
nm.disp()
val nm1 = People("Vikash Dubay", 32)
nm1.disp()
}
*/
/** Primary and Secondary constructor **/
/*class Registration(val email:String,val password:String)
{
//Properties
var hName:String=""
var hAge:Int? = null
var hEmail:String
var hPassword:String
var gender:String = "Female"
//Secondary constructor
constructor(val name:String,val age:Int,val email: String,val password: String):this(email,password)
{
hName = name
hAge = age
}
//Init Block
init{
hPassword = password
}
//Member Function
fun disp()
{
println("The name are : $hName")
println("Age $hAge")
println("Email $hEmail")
println("Password $hPassword")
print("Gender $gender")
}
}
fun main()
{
val nm = Registration() // Enter the data
nm.disp()
}
*/