tw-oocamp-201512 / the-code-of-you

使用你最喜欢的语言写一段代码来介绍你自己,提交在Issues里
1 stars 1 forks source link

Du Juan's Introduction #6

Open dujuanxian opened 8 years ago

dujuanxian commented 8 years ago
import java.lang.String;
import java.lang.System;
import java.util.Arrays;
import java.util.List;
import java.lang.Thread;

public class Self {
    String name = "Du Juan";
    String skype = "juanduxian";
    String github = "dujuanxian";

    public static void main(String[] args) {
        Self self = new Self();
        self.introduceName();
        self.introduceCareers();
        self.introduceContacts();
    }

    private void fancyPrint(String line) {
        for(char value: line.toCharArray()) {
            System.out.print(value);
            try{
                Thread.sleep(50);
            }catch(InterruptedException ex) {}
        }
        System.out.println();
    }

    private void introduceName() {
        this.fancyPrint("Hi, everone!");
        this.fancyPrint("My name is " + this.name);
    }

    private void introduceCareers() {
        Career backend = new Career(Role.BACKEND_DEV, "2012", Arrays.asList("Java"));
        this.fancyPrint(backend.getIntroduction());

        Career frontend = new Career(Role.FRONTEND_DEV, "2014", Arrays.asList("Javascript"));
        this.fancyPrint(frontend.getIntroduction());
    }

    private void introduceContacts() {
        this.fancyPrint("Find me here:");
        this.fancyPrint("Skype: " + this.skype);
        this.fancyPrint("Github: " + this.github);
    }
}

class Career {
    private Role role;
    private String startDate;
    private List<String> languages;

    public Career(Role role, String startDate, List<String> languages) {
        this.role = role;
        this.startDate = startDate;
        this.languages = languages;
    }

    public String getIntroduction() {
        return "In " + this.startDate + ", " +
                "I started to be a " + this.role.getName() +
                " using " + String.join(", " , this.languages);
    }
}

enum Role {
    FRONTEND_DEV("Frontend Developer"), BACKEND_DEV("Backend Developer");

    private String name;

    private Role(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }
}
dujuanxian commented 8 years ago

Hi, everone! My name is Du Juan In 2012, I started to be a Backend Developer using Java In 2014, I started to be a Frontend Developer using Javascript Find me here: Skype: juanduxian Github: dujuanxian