-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops.java
More file actions
64 lines (54 loc) · 1.35 KB
/
Copy pathoops.java
File metadata and controls
64 lines (54 loc) · 1.35 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
public class oops{
public static void main(String args[]){
Pen p1 = new Pen();
p1.setColor("Red");
p1.setTip(10);
System.out.println(p1.color);
p1.color = "Yellow";
System.out.println(p1.tip);
System.out.println(p1.color);
Bankaccount myacc = new Bankaccount();
myacc.username = "Nikhilxys";
myacc.setPassword("9fdjn");
System.out.println(myacc.username);
//System.out.println(myacc.password);
Vehicle v1 = new Vehicle();
v1.Setcompany("Hero");
v1.model = 2012;
System.out.println(v1.company);
}
}
class Bankaccount{
public String username;
private String password;
public void setPassword(String pwd){
password = pwd;
}
}
class Pen{
String color;
int tip;
void setColor(String newcolor){
color = newcolor;
}
void setTip(int newtip){
tip = newtip;
}
}
//getters setters...
class Vehicle{
String company;
int model;
String Setcompany(String company){
return this.company = company;
}
int Setmodel(int model){
return this.model= model;
}
String getcompany(){
return this.company;
}
int getmodel(){
return this.model;
}
}