/**
 * {@link <a href=
 * "https://[Log in to view URL]"
 * target= "_blank">Cast su interfacce</a>}
 * 
 * @author itammb ( Italia Massimiliano Buscati )
 * @version JDK 1.15
 *
 */
class Main {
	@FunctionalInterface
	public static interface Content {
		public Content solveProblem(Content content);
	}

	public static interface Professor {
		public Content teach(Content content);

		public Credit review(Content content, Student student);
	}

	public static interface Credit {
		public int amount(Content content);
	}

	@FunctionalInterface
	public static interface Student {
		public Content learn(Content content);
	}

	public static abstract class Identity {
		private int identity;
		private String generality;

		public Identity(int identity, String generality) {
			this.identity = identity;
			this.generality = generality;
		}

		@Override
		public String toString() {
			return this.identity + " " + this.generality;
		}
	}

	public static class HeadDepartment extends Identity implements Professor {

		public HeadDepartment(int identity, String generality) {
			super(identity, generality);
		}

		public Content teach(Content content) {
			return content;
		}

		public Credit review(Content content, Student student) {
			return new Credit() {
				public int amount(Content content) {
					return 0;
				}
			};
		}
	}

	public static void main(String args[]) throws Exception {
		// Unit test - Cast su oggetti
		HeadDepartment headDepartment = new HeadDepartment(0, "itammb");
		System.out.println(headDepartment);

		System.out.println(headDepartment instanceof Professor);
		Professor professor = (Professor) headDepartment;
		System.out.println(professor);

		System.out.println(professor instanceof HeadDepartment);
		headDepartment = (HeadDepartment) professor;
		System.out.println(headDepartment);

		professor = new Professor() {
			public Content teach(Content content) {
				return content;
			}

			public Credit review(Content content, Student student) {
				return new Credit() {
					public int amount(Content content) {
						return 0;
					}
				};
			}
		};

		System.out.println(professor instanceof HeadDepartment);

		headDepartment = (HeadDepartment) professor;
	}  
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: