-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass1.java
More file actions
32 lines (28 loc) · 762 Bytes
/
Class1.java
File metadata and controls
32 lines (28 loc) · 762 Bytes
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
public class Class1{
public static void main(String[] args){
Pen cello = new Pen();
//Pen1
cello.name = "Cello";
cello.color = "Red";
cello.type = "Ball Pen";
// Pen2
Pen goldex = new Pen();
goldex.name = "goldex";
goldex.color = "blue";
goldex.type = "Ball Pen";
// cello.getInfo();
cello.printColor();
goldex.printColor();
}
}
class Pen{
String name;
String color;
String type; // ball pen or gel pen
public void getInfo(){
System.out.println("Great pen");
}
public void printColor(){
System.out.println("We have " + this.name + " pen in " + this.color + " color.");
}
}