-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetGetInheritance.java
More file actions
146 lines (115 loc) · 2.95 KB
/
setGetInheritance.java
File metadata and controls
146 lines (115 loc) · 2.95 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.petehouston.tutorial.java;
import com.sun.nio.sctp.PeerAddressChangeNotification;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.String;
public class HelloWorld {
public static void main(String[] args) throws IOException {
// Cat p = new Cat("Meiirzhan",21);
// System.out.println(p.getAge());
// p.setAge(18);
// System.out.println(p.getAge());
// p.setAge(370);
// System.out.println(p.getAge());
// Person tom = new Person();
// Person bob = new Person();
//
// tom.displayId();
// bob.displayId();
// System.out.println(Person.counter);
//
// Person.counter = 8;
// Person sam = new Person();
// sam.displayId();
// double radius = 60;
//
// System.out.printf("Radius: %f \n", radius);
// System.out.printf("Area: %f \n", Math.PI * radius);
// User user = new User("mylogin","mypassword");
//
// System.out.println("Login: " + user.getLogin());
// System.out.println("Password: " + user.getPassword());
Employee sam = new Employee("Sam", "Meta");
sam.display();
}
}
class People{
private String name;
public String getName(){ return name; }
public People(String name){
this.name = name;
}
public void display(){
System.out.println("Name: " + name);
}
}
class Employee extends People{
private String company;
public Employee(String name, String company){
super(name);
this.company = company;
}
@Override
public void display(){
super.display();
// System.out.println("Name: " + getName());
System.out.printf("%s works in %s ! \n",getName(),company);
}
}
class User{
private String login;
private String password;
public User(String login, String password){
this.login = login;
this.password = password;
}
public String getLogin(){
return login;
}
public void setLogin(String login){
this.login = login;
}
public String getPassword(){
return password.charAt(0) + "******";
}
public void setPassword(String password){
this.password = password;
}
}
class Math{
public static final double PI = 3.14;
}
class Person{
private int id;
static int counter = 1;
Person(){
id = counter++;
}
public void displayId(){
System.out.printf("Id: %d \n",id);
}
}
class Cat{
private String name;
private int age = 1;
public Cat(String name, int age){
this.name = name;
this.age = age;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public int getAge(){
return age;
}
public void setAge(int age){
if(age > 0 && age < 110){
this.age = age;
}
}
}