-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathddfdf.java
More file actions
38 lines (32 loc) · 948 Bytes
/
ddfdf.java
File metadata and controls
38 lines (32 loc) · 948 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
33
34
35
36
37
38
public class ddfdf{
public static void main(String[] args) {
Face bob = new Face(); // вызов первого конструктора без параметров
bob.displayInfo();
Face tom = new Face("Tom"); // вызов второго конструктора с одним параметром
tom.displayInfo();
Face sam = new Face("Sam", 25); // вызов третьего конструктора с двумя параметрами
sam.displayInfo();
}
}
class Face{
String name; //
int age; // возраст
Face()
{
name = "Undefined";
age = 18;
}
Face(String n)
{
name = n;
age = 18;
}
Face(String n, int a)
{
name = n;
age = a;
}
void displayInfo(){
System.out.printf("Name: %s \tAge: %d\n", name, age);
}
}