public class test {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
System.out.println("到访地点:");
choose(scanner.next());
}
public static void information()
{
Scanner scanner=new Scanner(System.in);
System.out.println("输入个人信息:");
Boos.Set(scanner.next(),scanner.nextInt(),scanner.next());
System.out.println(Boos.getPerson().toString());
Boos.getBoos();
}
public static void choose(String location){
if (location.equals("广州")){
guangZhou();
}else if (location.equals("北京")){
beiJing();
}else if (location.equals("上海")){
shangHai();
}
}
public static void guangZhou()
{
information();
System.out.println("阿里总裁"+Boos.getPerson().getName()+",到广州访问");
}
public static void beiJing(){
information();
System.out.println("阿里总裁"+Boos.getPerson().getName()+",到北京访问");
}
public static void shangHai(){
information();
System.out.println("阿里总裁"+Boos.getPerson().getName()+",到上海访问");
}
}
class Boos {
private static Boos boos=null;
private static Person person;
private Boos() {}
public static Boos getBoos() {
if (boos==null){
synchronized (Boos.class){
if (boos==null){
boos=new Boos();
}
}
}
return boos;
}
public static void Set(String name,int age,String sex)
{
person=new Person(name,age,sex);
}
public static Person getPerson() {
return person;
}
}
class Person{
private String name;
private int age;
private Gen sex;
public Person(String name, int age, String sex) {
this.name = name;
this.age = age;
if (sex.equals("男"))
{
this.sex = Gen.Male;
}else {
this.sex=Gen.Female;
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Gen getSex() {
return sex;
}
public void setSex(Gen sex) {
this.sex = sex;
}
@Override
public String toString() {
return "Person{" +
"name='" + name + '\'' +
", age=" + age +
", sex=" + sex +
'}';
}
}
enum Gen{
Male,Female;
}