I need help with this assignment Write a Java program using

I need help with this assignment.

Write a Java program using object-oriented techniques.This program needs to manage the settings of an online video game.

It must support the following operations:

Method to request a userID and password, each as a string

Method to request the wanted video resolution as a string

(valid settings: 800x600, 1024x768, 1152x900)

Method to request computer information each as an integer

(use: RAM size, HD free space, video card RAM size)

Method (or methods) to display the selected settings to the user for verification. If the data entered is not accepted, request the information again (note: it is fine to request ALL the information again, it is not necessary to only request specific info to be re-entered, but you can if you would like)

The class/object should hold the primitive values listed above (such as: userID, resolution, etc.) but it should not allow the values to be altered directly. The programmer should be required to use “get” and “set” methods instead. The “set” method for the video resolution should verify that the selected value entered by the user is one of the valid settings listed above.

This assignment does require use of a class and to instantiate at least one object, but it does not need to utilize polymorphism, inheritance, the use of an interface, etc. It does require encapsulation, as suggested by the “get” and “set” method requirements, otherwise it is best to keep it simple.

Example input:

userID: Elvis Presley

password: Graceland

video resolution: 1024x768

Ram size (in whole GB): 16

HD free space (in whole GB): 550

Video card RAM size (GB): 4

This is what i have so far:

public class Encapsulation{
private String userID;
private String password;
private String resolution;
private int Ramsize;
private int freespace;
private int videocard;

//Get and Set methods
public String getuserID(){
return userID;
}

public String getpassword(){
return password;
}

public String getresolution(){
return resolution;
}
public int getRamsize(){
   return Ramsize;
}

public int getfreespace(){
   return freespace;
}
public int getvideocard(){
   return videocard;
}
public void setuserID(String newuserID){
userID = newuserID;
}

public void setpassword(String newpassword){
password = newpassword;
}

public void setresolution(String newresolution){

resolution = newresolution;
}
public void setRamsize (int newRamsize){
   Ramsize = newRamsize;
}
public void setfreespace (int newfreespace){
   freespace = newfreespace;
}
public void setvideocard (int newvideocard){
   videocard = newvideocard;
}
}

Solution

Please create three java class

The main class is GameConfigurationUserInput.java

Please copy paste the below code in the following three classes.

1) GameConfigurationUserInput

public class GameConfigurationUserInput {
  
public static void main(String[] args) {
   GetVideoGameSetting vGS = new GetVideoGameSetting();
   GameConfiguration gameConfiguration = vGS.getVideoSetting();
  
   System.out.println(\"You have input the following information \");
   System.out.println(gameConfiguration.toString());
  
      
   }
}

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

2) GetVideoGameSetting

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class GetVideoGameSetting {
   Scanner scanner = new Scanner(System.in);

   public GameConfiguration getVideoSetting() {
       List<String> validVideoResolutionList = new ArrayList<String>();
       validVideoResolutionList.add(\"800x600\");
       validVideoResolutionList.add(\"1024x768\");
       validVideoResolutionList.add(\"1152x900\");
       GameConfiguration gc = new GameConfiguration();
      
       System.out.print(\"Please enter userID : \");
       gc.setUserID(getUsername());
       System.out.print(\"Please enter password : \");
       gc.setPassword(getPassword());

       System.out.print(\"Please enter video Resolution : \");
       String videoResolution = getVideoResolution();
       if (validateVideoResolution(validVideoResolutionList, videoResolution)) {
           gc.setResolution(videoResolution);
       } else {
           while(true){
               System.out.println(\"Please enter a valid video resolution, valid resolutions are \"
                       + validVideoResolutionList.toString());
               String videoResolutionNew = getVideoResolution();
               if(validateVideoResolution(validVideoResolutionList,videoResolutionNew)){
                   gc.setResolution(videoResolutionNew);
                   break;
               }
           }
       }
      
       System.out.print(\"Please enter ram size in gb : \");
       String ramSize = getRamSize();
       if (validateInteger(ramSize)){
           gc.setRamSize(Integer.parseInt(ramSize));
       }else{
           while(true){
               System.out.println(\"Please enter ram size in a valid number format \");
               String ramSizeNew = getRamSize();
               if (validateInteger(ramSizeNew)){
                   gc.setRamSize(Integer.parseInt(ramSizeNew));
                   break;
               }
           }
       }
      
       System.out.print(\"Please enter free space in gb : \");

       String freeSpace = getFreeSpace();
       if (validateInteger(freeSpace)){
           gc.setFreeSpace(Integer.parseInt(freeSpace));
       }else{
           while(true){
               System.out.println(\"Please enter free space in a valid number format \");
               String freeSpaceNew = getFreeSpace();
               if (validateInteger(freeSpaceNew)){
                   gc.setFreeSpace(Integer.parseInt(freeSpaceNew));
                   break;
               }
           }
       }
       System.out.print(\"Please enter video card ram size in gb : \");

       String videoCardRamSize = getVideoCardRamSize();
       if (validateInteger(videoCardRamSize)){
           gc.setVideoCardRamSize(Integer.parseInt(videoCardRamSize));
       }else{
           while(true){
               System.out.println(\"Please enter video card ram size in a valid number format \");
               String videoCardRamSizeNew = getVideoCardRamSize();
               if (validateInteger(videoCardRamSizeNew)){
                   gc.setVideoCardRamSize(Integer.parseInt(videoCardRamSizeNew));
               }
           }
       }
       return gc;
   }

   private String getUsername() {
      
       String username = scanner.next();
       return username;
   }

   private String getPassword() {

       String password = scanner.next();
       return password;
   }

   private String getVideoResolution() {
      
       String videoResolution = scanner.next();
       return videoResolution;
   }

   private String getRamSize() {
      
       String ramSize = scanner.next();
       return ramSize;
   }

   private String getFreeSpace() {
       String freeSpace = scanner.next();
       return freeSpace;
   }

   private String getVideoCardRamSize() {
       String videoCardRamSize = scanner.next();
       return videoCardRamSize;
   }

   private boolean validateVideoResolution(
           List<String> validVideoResolutionList, String videoResolution) {

       if (validVideoResolutionList.contains(videoResolution))
           return true;
       else {
           return false;

       }

   }
  
   private boolean validateInteger(String size){
       try{
           int space = Integer.parseInt(size);
           return true;
       }catch(Exception e){
           return false;
       }
   }
}

---------------------------------------------------------------------------------------------------------------------------------------------------------------

3) GameConfiguration

public class GameConfiguration {
   private String userID;
private String password;
private String resolution;
private int ramSize;
private int freeSpace;
private int videoCardRamSize;
   /**
   * @return the userID
   */
   public String getUserID() {
       return userID;
   }
   /**
   * @param userID the userID to set
   */
   public void setUserID(String userID) {
       this.userID = userID;
   }
   /**
   * @return the password
   */
   public String getPassword() {
       return password;
   }
   /**
   * @param password the password to set
   */
   public void setPassword(String password) {
       this.password = password;
   }
   /**
   * @return the resolution
   */
   public String getResolution() {
       return resolution;
   }
   /**
   * @param resolution the resolution to set
   */
   public void setResolution(String resolution) {
       this.resolution = resolution;
   }
   /**
   * @return the ramSize
   */
   public int getRamSize() {
       return ramSize;
   }
   /**
   * @param ramSize the ramSize to set
   */
   public void setRamSize(int ramSize) {
       this.ramSize = ramSize;
   }
   /**
   * @return the freeSpace
   */
   public int getFreeSpace() {
       return freeSpace;
   }
   /**
   * @param freeSpace the freeSpace to set
   */
   public void setFreeSpace(int freeSpace) {
       this.freeSpace = freeSpace;
   }
   /**
   * @return the videoCardRamSize
   */
   public int getVideoCardRamSize() {
       return videoCardRamSize;
   }
   /**
   * @param videoCardRamSize the videoCardRamSize to set
   */
   public void setVideoCardRamSize(int videoCardRamSize) {
       this.videoCardRamSize = videoCardRamSize;
   }
   /* (non-Javadoc)
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString() {
       return \"GameConfiguration [userID=\" + userID + \", password=\" + password
               + \", resolution=\" + resolution + \", ramSize=\" + ramSize
               + \", freeSpace=\" + freeSpace + \", videoCardRamSize=\"
               + videoCardRamSize + \"]\";
   }
  
}

Compile and run

Please Compile GameConfigurationUserInput.java and execute the GameConfigurationUserInput.class file

Output will look like as below example

Please enter userID : abcd
Please enter password : efgh
Please enter video Resolution : 800x600
Please enter ram size in gb : 8
Please enter free space in gb : 360
Please enter video card ram size in gb : 1
You have input the following information
GameConfiguration [userID=abcd, password=efgh, resolution=800x600, ramSize=8, freeSpace=360, videoCardRamSize=1]

I need help with this assignment. Write a Java program using object-oriented techniques.This program needs to manage the settings of an online video game. It mu
I need help with this assignment. Write a Java program using object-oriented techniques.This program needs to manage the settings of an online video game. It mu
I need help with this assignment. Write a Java program using object-oriented techniques.This program needs to manage the settings of an online video game. It mu
I need help with this assignment. Write a Java program using object-oriented techniques.This program needs to manage the settings of an online video game. It mu
I need help with this assignment. Write a Java program using object-oriented techniques.This program needs to manage the settings of an online video game. It mu
I need help with this assignment. Write a Java program using object-oriented techniques.This program needs to manage the settings of an online video game. It mu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site