I have only been working with Java for about a month. This is a silly code I wrote this morning supposedly buying a Robot or Cyborg from USA Manufactories. What do you think? Please focus more on the code than anything else. Is this sufficient work from a beginner such as myself or should I creating more complex code.
import java.util.Scanner; class Cyborg { String name; int age; void speak(String voice2) { System.out.println(voice2); } } class Robot { String name; int age; int height; // In terms of feet. void speak(String voice) { System.out.println(voice); } int grow() { return height; } } public class Manuf { public static void main(String[] args) { System.out.println("Welcome to USA Manufactories."); System.out .println("Here we have many different technologies, first up is Jack, the Robot."); System.out.println(""); Robot Jack = new Robot(); Jack.name = "Jack"; Jack.age = 20; Jack.height = 999; Jack.speak("Hello, my name is Jack."); System.out.print("I am now " + Jack.age + ". "); Jack.grow(); System.out.print("I have grown " + Jack.height + " feet."); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println("Next we a have a cyborg named Him."); Cyborg Him = new Cyborg(); Him.speak("Hello, my name is him. I am a cyborg."); System.out.println(""); System.out.println(""); System.out .println("Okay, now you must pick the Cyborg or robot. Which will it be?"); System.out.println("Press 1 for the Robot and 2 for the Cyborg."); Scanner choice = new Scanner(System.in); int picked = choice.nextInt(); System.out.println("Great! You picked choice " + picked + "."); switch (picked) { case 1: System.out.println("How would you like to pay for your Robot?"); break; case 2: System.out.println("How would you like to pay for your Cyborg?"); break; default: System.out.println("Since you did not pick an option, it will be mailed to you."); break; } System.out.println("Press 3 for Cash, 4 for Check, or 5 for the bill to be mailed to you."); Scanner payment = new Scanner(System.in); int paymentMethod = payment.nextInt(); switch (paymentMethod) { case 3: System.out.println("Thank you for using USA Manufactories, come again."); break; case 4: System.out.println("Thank you for using USA Manufactories, come again."); break; case 5: System.out.println("Thank you for using USA Manufactories, come again. Your bill should come shortly."); break; default: break; } } }
Thanks!