Need help Visit: https://programmingbydoing.com/ Create a BlueJ project with a n
ID: 3707619 • Letter: N
Question
Need help
Visit: https://programmingbydoing.com/ Create a BlueJ project with a new class called AltArray. Complete each of the following sections from the website within that class. (5 pts per problem) ? 138 o 139 o 140 ? 142 o 144 ? 145 o 147 ? 149 o 150 o 151 Within that same BlueJ project, create a new class called ResequencingGame. Write an app fo the game as described. (50 points) Make an array resequencing puzzle game. Your game will start with the numerical array 123456789, where each digit is an element in an array of integers. The computer will permute the array to a random order. Example: 947385216 The computer will ask the user how many numbers to reverse. If the player says 4, the computer will reverse the first 4 numbers of the array Example: 374985216 The computer will ask the user how many numbers to reverse. If the player says 6, the computer will reverse the first 6 numbers of the array. Example: 589473216Explanation / Answer
Note: As per your Requirement i coded the code in java.....Check it revert back if you have any queries or doubts....happy Coding!!
////////////////////ResequencingGame.java////////////////////
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class ResequencingGame{
public static List<Integer> Reverse(List<Integer> gameList, int input) {
List<Integer> list = new ArrayList<>();
for(int i = input-1; i>=0;i--){
list.add(gameList.get(i));
}
for(int i=0;i<list.size();i++){
gameList.set(i, list.get(i));
}
return gameList;
}
public static void main(String[] args) {
List<Integer> GameList = new ArrayList<Integer>();
for(int i=1;i<10;i++){
GameList.add(i);
}
List<Integer> CopyGameList = new ArrayList<>(GameList);
System.out.println("Goal State :"+ GameList);
Collections.shuffle(GameList);
System.out.println("Your Start State:"+GameList);
System.out.println("Let's Game Starts.....");
while (1>0) {
System.out.println("Input for your Reverse Ordering:");
Scanner sc = new Scanner(System.in);
int Input = sc.nextInt();
if(Input<10 && Input>0){
GameList = Reverse(GameList,Input);
if(GameList.equals(CopyGameList)){
System.out.println("Hurray.....You Reached to Goal State...You Won the Game....");
break;
}
System.out.println("Reversed List: "+GameList);
}
else{
System.out.println("Please Select the index within the Range.....Try Once.....");
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.