Question: Need help with High Score Manager assignment in Java. I'm very confused at this time because my code isn't running. Got a sample answer here

Need help with High Score Manager assignment in Java. I'm very confused at this time because my code isn't running. Got a sample answer here and modified it to suit my assignment but the code isn't running. I have till midnight to submit this assignment and this is the last day for late submission. Please help.

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.util.Scanner;

public class HighScoreManager {

private static Scanner sc;

private static FileOutputStream results;

public HighScoreManager(String username, int score, String date) {

// TODO Auto-generated constructor stub

}

public static void main(String[] args) {}

public static class User extends HighScoreManager {

private static String score;

String username,userInfo,date;

private byte[] highscore;

public User(String username, int score, String date) { //constructor

super(username, score, date);

}

public User(String username, String userinfo) {

super(username, 0, userinfo);

this.username = username;

}

public boolean checkUserExist(String actualUser){ //checking userexist or not

boolean result = false;

if(actualUser.equals(this.username)){

result = true;

}

return result;

}

public void updateUserExist(String name){ //updating user details

this.username = name;

}

}

public static void main1(String args[]) throws FileNotFoundException, IOException{

sc = new Scanner(System.in);

User[] userrecords = new User[10]; //storing array of records

int records = 0;

User newUser = new User("Matthew","Matthew new user");//creating new records

System.out.println("Enter an option. ");

String checkName = sc.nextLine();

if(newUser.checkUserExist(checkName) == true){ //checking

while(true){

//printing menu

System.out.println(" 1. Add new player and score. 2. Print all players and score. 3. Search for a player's score. 4. Remove a player. 5. Quit. ");

int choice = sc.nextInt();

if(choice == 1){ //updating user details

System.out.println("Enter new player name: ");

String name = sc.nextLine();

newUser.updateUserExist(name);

}

else if(choice == 2){ //printing records

for(int i=0;i

System.out.println(userrecords[i].username+" "+User.score);

}

}

else if(choice == 3){ //creating new highscore record

System.out.println("Enter user name");

String name = sc.nextLine();

System.out.println("Enter score");

int score = sc.nextInt();

System.out.println("Enter date");

String date = sc.nextLine();

User user = new User(name,score,date);

results = new FileOutputStream(" ");

results.write(user.highscore);

records++;

}

else{ //exiting

break;

}

}

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!