Source Code
Session7.java
import java.util.*;
public class Session7 {
public static void main(String[] args) {
String myName = ""; // add your name
System.out.println("Session 7" + " - " + 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();
break;
case "E4":
System.out.println("Example 4");
example4();
break;
case "E5":
System.out.println("Example 5");
example5();
break;
case "E6":
System.out.println("Example 6");
example6();
break;
case "E7":
System.out.println("Example 7");
example7();
break;
case "E8":
System.out.println("Example 8");
example8();
break;
case "Q":
System.out.println("Quitting..!");
break;
default:
System.out.println("Invalid Choice");
}
}
// example1 method
public static void example1() {
// create counter object
// increment counter
// print counter value
// reset counter value
// click twice and print the value
}
// example2 method
public static void example2() {
// create dice object
// print the string representation of the object
// call the roll method
// print the string representation of the object
// call the roll method
// print the string representation of the object
// getFaceValue example
}
// example3 method
public static void example3() {
// create new person object
// call sayHello method
}
// example4 method
public static void example4() {
// create new person object
// call sayHello method
}
// example5 method
public static void example5() {
// create new object sam
// print sam
// deposit $100
// withdraw $50
}
// example6 method
public static void example6() {
// create a new object teddi
// print teddi
// deposit $500
}
// example7 method
public static void example7() {
// create a new object devin
// withdraw $250
}
// example8 method
public static void example8() {
// create a new object jada
}
}
Counter.java
// class header
public class Counter {
// private instance variable(s)
// Constructor
// accessor method(s)
// mutator method(s)
}
Dice.java
// class header
public class Dice {
// private instance variable
// Constructor
// roll method
// getFaceValue method
// toString method
}
Person.java
// header
public class Person {
// private instance variables
// Constructors
// no arguments
// Constructor with parameters
// method(s)
}
BankAccount.java
// header
public class BankAccount {
// private instance variables
// constructors
// no argument constructor
// one argument constructor
// two argument constructor
// three argument constructor
// methods
// deposit method
// withdraw method
// getBalance method
// toString method returns a string representation of this die.
}
Last updated