Switch-Case

  • TextGame Example for Project 1.4

     


    import java.util.Scanner;
    public class Swtiches31 {
    public static void main(String[] args) {
         Scanner Bob = new Scanner(System.in);
         String Menu = "Please select\n"
              + "1 for Allygators\n"
              + "2 for Ravens\n"
              + "3 for Regional Managers";
         String AllygatorString = "yes, Allygators";
         String RavenString = "Squawt - Ravens";
         String OfficeString = "Beets, Battlestar";
         String WhatString = "That is not 1,2, or 3";
         int choice = 0;
    //Asking and Getting
         System.out.println(Menu);//prints our menu
         choice = Bob.nextInt();//holds choice from menu
          switch(choice)
         {
              case 1: System.out.println(AllygatorString);
              break;
              case 2: System.out.println(RavenString);
              break;
              case 3: System.out.println(OfficeString);
              break;
              default: System.out.println(WhatString);
         }
    System.out.println("Thank you!");

    }

    }

Avatar Basic Code

  • var body = new THREE.SphereGeometry(100);
    var cover = new THREE.MeshNormalMaterial(flat);
    var avatar = new THREE.Mesh(body, cover);
    scene.add(avatar);
    var hand = new THREE.SphereGeometry(50);
    var rightHand = new THREE.Mesh(hand, cover);
    rightHand.position.set(-150,0,0);
    avatar.add(rightHand);
    var leftHand = new THREE.Mesh(hand, cover);
    leftHand.position.set(150,0,0);
    avatar.add(leftHand);
    var rightFoot = new THREE.Mesh(hand, cover);
    rightFoot.position.set(-75,-125,0);
    avatar.add(rightFoot);
    var leftFoot = new THREE.Mesh(hand, cover);
    leftFoot.position.set(75,-125,0);
    avatar.add(leftFoot);
    var heed = new THREE.SphereGeometry(70);
    var Head = new THREE.Mesh(heed, cover);
    avatar.add(Head);
    Head.position.set(0,150,0);
    var isCartWheeling = false;
    var isFlipping = false;
    function animate(){
    requestAnimationFrame(animate);
    if(isCartWheeling){avatar.rotation.z = avatar.rotation.z + 0.05;}
    if(isFlipping){avatar.rotation.x = avatar.rotation.x + 0.05;}
    renderer.render(scene, camera);
    }
    animate();
    document.addEventListener('keydown', downloadKey);
    function downloadKey(event)
    {
    //alert(event.code);
    var code = event.code;
    if(code == 'ArrowLeft'){avatar.position.x = avatar.position.x - 5;}
    if(code == 'ArrowRight'){avatar.position.x = avatar.position.x + 5;}
    if(code == 'ArrowUp'){avatar.position.z = avatar.position.z - 5;}
    if(code == 'ArrowDown'){avatar.position.z = avatar.position.z + 5;}
    if(code == 'KeyC'){isCartWheeling = !isCartWheeling;}
    if(code == 'KeyF'){isFlipping = !isFlipping;}
    }