Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.reflect.Array;
- import java.util.Scanner;
- /**
- * PersonalCodeBehaviour
- */
- interface PersonalCodeBehaviour {
- public String getGender();
- public String[] getBirthday(String isikukood);
- public String getYear(String[] birthdayArray);
- public String getMonth(String[] birthdayArray);
- public String getDay(String[] birthdayArray);
- }
- class EstonianID implements PersonalCodeBehaviour {
- private String isikukood;
- public EstonianID(String isikukood) {
- this.isikukood = isikukood;
- String[] birthdayArray = isikukood.split("-", 3);
- }
- // public int getGender(String gender) {
- // if (gender == "mees") {
- // return 1;
- // } else if (gender == "naine") {
- // return 2;
- // } else {
- // return 0;
- // }
- // }
- public String[] getBirthday() {
- String[] birthdayArray = isikukood.split("-", 3);
- return birthdayArray;
- }
- public String getYear() {
- String year = birthdayArray[2];
- return year;
- }
- public String getMonth(String[] birthdayArray) {
- String month = birthdayArray[1];
- return month;
- }
- public String getDay(String[] birthdayArray) {
- String day = birthdayArray[0];
- return day;
- }
- public String getGender(String isikukood) {
- String gender = String.valueOf(isikukood.indexOf(0));
- return gender;
- }
- }
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Eesti ID - 1 | Soome ID - 2");
- int option = scanner.nextInt();
- // EstonianID estonian = new EstonianID();
- // FinnishID finnish = new FinnishID();
- if (option == 1) {
- option = scanner.nextInt();
- //scanner.nextLine();
- if (option == 1) {
- System.out.println("Sisestage oma isikukood: ");
- String isikukood = scanner.nextLine();
- EstonianID estonian = new EstonianID(isikukood);
- System.out.println(estonian);
- } else if (option == 2) {
- System.out.println("Sisestage oma isikukood: ");
- String isikukood = scanner.nextLine();
- EstonianID estonian = new EstonianID(isikukood);
- } else {
- System.out.println("Palun sisestage kas 1 voi 2!");
- }
- scanner.close();
- }
- }
- }
- // public class FinnishID implements PersonalCodeBehaviour {
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement