Skip to content

Instantly share code, notes, and snippets.

@dgreenhalgh
Created October 4, 2018 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgreenhalgh/ecb25561d711769d4ab45e981a173a7d to your computer and use it in GitHub Desktop.
Save dgreenhalgh/ecb25561d711769d4ab45e981a173a7d to your computer and use it in GitHub Desktop.
Big Nerd Ranch Java Interoperability - Jhava
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.util.function.Function;
public class Jhava {
private int hitPoints = 52489112;
private String greeting = "BLARGH";
public static void main(String[] args) {
System.out.println(Hero.makeProclamation());
System.out.println("Spells:");
Spellbook spellbook = new Spellbook();
for (String spell : spellbook.spells) {
System.out.println(spell);
}
System.out.println("Max spell count: " + Spellbook.MAX_SPELL_COUNT);
Spellbook.getSpellbookGreeting();
Function1<String, Unit> translator = Hero.getTranslator();
translator.invoke("TRUCE");
}
@NotNull
public String utterGreeting() {
return greeting;
}
@Nullable
public String determineFriendshipLevel() {
return null;
}
public int getHitPoints() {
return hitPoints;
}
public String getGreeting() {
return greeting;
}
public void setGreeting(String greeting) {
this.greeting = greeting;
}
public void offerFood() {
Hero.handOverFood("pizza");
}
public void extendHandInFriendship() throws Exception {
throw new Exception();
}
public void apologize() {
try {
Hero.acceptApology();
} catch (IOException e) {
System.out.println("Caught!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment