Popcorn Hack
class Bro {
static String name;
static String catchphrase = "Sup bro?";
public Bro(String name) {
this.name = name;
}
public static void sayHi() {
System.out.println("Hey, I'm " + name);
}
public static void sayCatchphrase() {
System.out.println(catchphrase);
}
public static void main(String[] args) {
// Will this work?
sayCatchphrase();
// What about this one?
sayHi();
Bro alex = new Bro("Alex");
alex.sayHi();
alex.sayCatchphrase();
}
}
Bro.main(null);
Sup bro?
Hey, I'm null
Hey, I'm Alex
Sup bro?
Homework Hack: Ultimate Battle
class Soldier {
String name;
int power;
int health;
int speed;
void attack() {
System.out.println("You hit with 100 Damage");
};
void printStatus() {
System.out.println("You have full health");
};
}
public class Main {
public static void main(String[] args) {
Soldier soldier = new Soldier();
soldier.attack();
soldier.printStatus();
System.out.println("BATTLE HAS STARTED!");
}
}
Main.main(null);
You hit with 100 Damage
You have full health
BATTLE HAS STARTED!