Session 22
Source Code
import java.util.*;
public class Week22 {
public static void main(String[] args) {
String myName = ""; // add your name
System.out.println("Week 22" + " - " + myName);
// Menu
System.out.println("Menu");
System.out.println("E1 - Example 1");
System.out.println("Q - Quit");
// setup Scanner
Scanner in = new Scanner(System.in);
System.out.print("Choice: ");
String choice = in.nextLine();
// switch choices
switch (choice) {
case "E1":
System.out.println("Example 1");
example1();
break;
case "E2":
System.out.println("Example 2");
example2();
break;
case "E3":
System.out.println("Example 3");
example3();
case "Q":
System.out.println("Quitting..!");
break;
}
}
// example1 method
public static void example1() {
// This creates a GameCharacter object.
// This creates a BossCharacter object,
// but stores it in a GameCharacter reference.
// This creates a BossCharacter object,
// stored in a BossCharacter reference.
}
// example2 method
public static void example2() {
String s1 = "hello";
String s2 = "hello";
// .equals()
// equality
// new String
}
// example3 method
public static void example3() {
// "Fortnite" (Battle Royale) - Max Players: 100
// "Minecraft" (Sandbox) - Max Players: 10
}
}
SeeNSayToy.java
ShoppingCartDemo2.java
Game.java
OnlineGame.java
MovieCollection.java
Last updated
Was this helpful?