Java Hello Hacks
public class Class1 {
public void Person(String name, int age){
System.out.println("The name of the person is: " + name + "The age of the person is: " + age);
}
public void Dessert(String type, int cost) {
System.out.println("The type of the dessert is: " + type + "The cost of the desert is: " + cost);
}
public static void main(String[] args){
Person person1 = new Person("Person1", 15);
Dessert dessert1 = new Dessert("Ice Cream", 15);
}
}
// Java Calculator Hack
public class
Java Console Hacks
// Showing the use of Hashmaps, Arrays, and Arraylists
import java.util.ArrayList; // import the ArrayList class
import java.util.HashMap; // import Hashmap Class
public class Class2{
public static void main(String[] args) {
// Fixed Array
numbers = new int[5];
int[] numbers = {1, 2, 3, 4, 5, 6};
System.out.println(numbers);
// ArrayList
ArrayList<String> integers = new ArrayList<String>();
integers.add("1");
integers.add("2");
integers.add("3");
integers.add("4");
System.out.println(integers);
// Different methods using ArrayList
// Changing at item in arraylist
integers.set(0, "1");
// Hashmap
HashMap<String, Int> people = new HashMap<String, Int>();
// Putting A Person Name and their Age
people.put("Person1", 15);
people.put("Person2", 16);
people.put("Person3", 17);
people.put("Person4", 18);
System.out.println(people);
}
}
import java.util.Scanner;
import java.util.Random;
public class RockPaperScissors {
public static void main(String[] args) {
// Getting input from the user
Scanner scanner = new Scanner(System.in);
System.out.println("Choose one: rock,paper,scissors");
String playerMove = scanner.nextLine();
// Getting input from the Opponent
Random random = new Random();
int othernumber = random.nextInt(3);
String opponentMove;
// If, else if, else statement:
if (othernumber == 0) {
opponentMove = "rock";
} else if (othernumber == 1) {
opponentMove = "paper";
} else {
opponentMove = "scissors";
}
System.out.println("Opponest chose: " + opponentMove + "!");
// Printing out opponent Move
}
}
Answer why you think this reorganization and AP indetification is important?
Reorgnaizations nad AP identification is important because they show what pices of code you are suppossed to use for your individual projects and requirments.