Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago