package me.blackphreak.Student.Types;

import com.google.gson.Gson;
import me.blackphreak.Student.AbstractStudent;

import static me.blackphreak.Lib.promptQuestion;

public class OverseaStudent extends AbstractStudent {
	private String _visa;
	
	public OverseaStudent() {}
	
	public OverseaStudent(String visa) {
		this._visa = visa;
	}
	
	@Override
	public void promptQuestionEx() {
		do {
			var inp = promptQuestion("    VISA: ", false)
					.toUpperCase();
			
			if (inp.isEmpty()
					|| inp.isBlank())
				System.out.println("Invalid VISA. Please try again.");
			else
				this.setVisa(inp);
		} while (this.getVisa() == null);
	}
	
	public String getVisa() {
		return _visa;
	}
	
	public void setVisa(String visa) {
		this._visa = visa;
	}
	
	@Override
	public String toJson() {
		try {
			return new Gson().toJson(this, OverseaStudent.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "";
	}
	
	@Override
	public void printInfoExtra() {
		System.out.println(String.format("    %13s: %s", "Visa", getVisa()));
	}
}
