package test3;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

public class Test3Utils {

	private Test3Utils() {
		
	}
	
	public static void initialize(SmartPhone phone) throws Exception {
		try {
			PhoneNumber n = PhoneNumber.getInstance(416, 736, 2100);
			Set<Contact> c = new TreeSet<>();
			Field number = SmartPhone.class.getDeclaredField("number");
			number.setAccessible(true);
			number.set(phone, n);
			Field contacts = SmartPhone.class.getDeclaredField("contacts");
			contacts.setAccessible(true);
			contacts.set(phone, c);			
		}
		catch (Exception x) {
			System.out.println(x);
			throw x;
		}
	}
	
	public static void initialize(CellPhone phone) throws Exception {
		try {
			CellNumber n = new CellNumber(416, 736, 2100);
			List<CellNumber> c = new ArrayList<>();
			Field number = CellPhone.class.getDeclaredField("number");
			number.setAccessible(true);
			number.set(phone, n);
			Field callLog = CellPhone.class.getDeclaredField("callLog");
			callLog.setAccessible(true);
			callLog.set(phone, c);
		}
		catch (Exception x) {
			System.out.println(x);
			throw x;
		}
	}
}
