-
Notifications
You must be signed in to change notification settings - Fork 0
/
Address.java
61 lines (49 loc) · 1.52 KB
/
Address.java
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
//create a class for containing different attributes for a address
import java.lang.Thread.State;
import java.util.Scanner;
public class Address {
private String street;
private String village;
private String state;
private String zip_code;
//getters and setters of above variables
public String getVillage() {
return village;
}
public void setVillage(String village) {
this.village = village;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZip_code() {
return zip_code;
}
public void setZip_code(String zip_code) {
this.zip_code = zip_code;
}
//accept the details about address from user
public void accept_address(){
Scanner s = new Scanner(System.in);
System.out.println("Enter your address (Street name, village name, State, Zip-Code)");
String add = s.nextLine();
String[] add_array = add.split(", ");
street = add_array[0];
village = add_array[1];
state = add_array[2];
zip_code = add_array[3];
}
//display the details about address from user
public void display_address(){
System.err.println(street+", "+village+", "+state+", "+zip_code);
}
}