he developers of a free online game named Sugar Smash have asked you to develop a class named SugarSmashPlayer that holds data about a single player. The class contains the following fields: idNumber - the player’s ID number (of type int), name - the player's screen name (of type String), scores - an array of integers that stores the highest score achieved in each of 10 game levels Include get and set methods for each field. The get method for scores should require the game level to retrieve the score for. The set method for scores should require two parameters—one that represents the score achieved and one that represents the game level to be retrieved or assigned. Display an error message if the user attempts to assign or retrieve a score from a level that is out of range for the array of scores. Additionally, no level except the first one should be set unless the user has earned at least 100 points at each previous level. If a user tries to set a score for a level that is not yet available, issue an error message. Create a class named PremiumSugarSmashPlayer that descends from SugarSmashPlayer. This class is instantiated when a user pays $2.99 to have access to 40 additional levels of play. As in the free version of the game, a user cannot set a score for a level unless the user has earned at least 100 points at all previous levels.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This is the question - The developers of a free online game named Sugar Smash have asked you to develop a class named SugarSmashPlayer that holds data about a single player. The class contains the following fields: idNumber - the player’s ID number (of type int), name - the player's screen name (of type String), scores - an array of integers that stores the highest score achieved in each of 10 game levels

Include get and set methods for each field. The get method for scores should require the game level to retrieve the score for. The set method for scores should require two parameters—one that represents the score achieved and one that represents the game level to be retrieved or assigned. Display an error message if the user attempts to assign or retrieve a score from a level that is out of range for the array of scores. Additionally, no level except the first one should be set unless the user has earned at least 100 points at each previous level. If a user tries to set a score for a level that is not yet available, issue an error message. Create a class named PremiumSugarSmashPlayer that descends from SugarSmashPlayer. This class is instantiated when a user pays $2.99 to have access to 40 additional levels of play. As in the free version of the game, a user cannot set a score for a level unless the user has earned at least 100 points at all previous levels.

Code I have that isn't accepted I ran out of word limit so I couldn't attach the last bit of my code, but the program dislikes everything I have so - 
import java.util.*;
public class DemoSugarSmash
{
   public static void main(String[] args)
   {
       System.out.println("SugarSmashPlayer Class Object1: ");
       SugarSmashPlayer sugarPlayer=new SugarSmashPlayer();
       sugarPlayer.setScreenName("Black");
       sugarPlayer.setID(1111);
       sugarPlayer.setScore(50, 0);
       sugarPlayer.setScore(70, 1);
       sugarPlayer.setScore(120, 2);
       System.out.println("SugarPlayer Name: "
       +sugarPlayer.getScreenName());
       System.out.println("SugarPlayer ID: "
       +sugarPlayer.getID());
       System.out.println("Score : "
                   +sugarPlayer.getScore(0));
       System.out.println("Score : "
                   +sugarPlayer.getScore(1));
       System.out.println("Score : "
                   +sugarPlayer.getScore(2));
       System.out.println();          
       System.out.println("PremiumSugarSmashPlayer Class Object1: ");
       PremiumSugarSmashPlayer premiumPlayer1=
               new PremiumSugarSmashPlayer(2.00);
       premiumPlayer1.setScore(15, 0);    
       premiumPlayer1.setID(1234);
       premiumPlayer1.setScreenName("Blue");    
       System.out.println("PremiumSugarSmashPlayer ID: "
               +premiumPlayer1.getID());
       System.out.println("PremiumSugarSmashPlayer Name: "
               +premiumPlayer1.getScreenName());
       System.out.println("PremiumSugarSmashPlayer Score: "
               +premiumPlayer1.getScore(0));
       System.out.println("\nPremiumSugarSmashPlayer Class Object2:");
       PremiumSugarSmashPlayer premiumPlayer=
               new PremiumSugarSmashPlayer(3.00);
       premiumPlayer.setID(321);            
       premiumPlayer.setScreenName("Thrones");
       premiumPlayer.setScore(15, 0);
       premiumPlayer.setScore(50, 1);
       premiumPlayer.setScore(20, 2);    
       System.out.println("PremiumSugarSmashPlayer ID: "
               +premiumPlayer.getID());    
       System.out.println("PremiumSugarSmashPlayer Name: "
               +premiumPlayer.getScreenName());    
       System.out.println("Premium User score who pay $3");
       System.out.println("Score : "
               +premiumPlayer.getScore(0));
       System.out.println("Score : "
               +premiumPlayer.getScore(1));
       System.out.println("Score : "
               +premiumPlayer.getScore(2));
   }
}
----------
public class PremiumSugarSmashPlayer extends SugarSmashPlayer
{
   private int[] scores=new int[40];
   private boolean accessLevel;
   public PremiumSugarSmashPlayer(double pay)
   {  
       if(pay>=2.99)
       {
           accessLevel=true;
       }
       else
       {
           accessLevel=false;
       }
   }
   public void setScore(int score, int gameLevel)
   {
       if(accessLevel)
       {
           if(gameLevel<0 ||gameLevel>scores.length)
           {
               System.out.println("Invalid Game level");
           }
           else
           {
               scores[gameLevel]=score;
           }    
       }
       else
       {
           System.out.println("Pay 2.99 to access levels:\n");
       }
   }
   public int getScore(int gameLevel)
   {
       if(gameLevel>=0 && gameLevel<scores.length )
       {
           return scores[gameLevel];
       }
       else
       {
           System.out.println("Invalid Game Level");
           return -1;
       }    
   }
}
-----
public class SugarSmashPlayer{
//write code here
   }
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Passing Array as Argument
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education