Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the promptInt method in class Global, a constructor for class PlayerShip reads input from the user and initialises the position field. Your code should

Using the promptInt method in class Global, a constructor for class PlayerShip reads
input from the user and initialises the position field. Your code should provide the String Player position: as a parameter to method promptInt. (Note that in the String there is
a space after the colon.) The following is an example of what this I/O looks like when the constructor executes (the bold and underlined text indicates the users input):
The PlayerShip constructor also creates two guns with power 5, with the first gun immediately one position to the left of the player ship, and the second gun immediately one position to the right of the player ship.
image text in transcribed
* Write a description of class PlayerShip here * author (your name) :vsi version nunber or a date) public class PlayerShip // instance variables replace the example below with your own private int position; private Gun gun1: private Gun gun2 public Playership() // initialise instance variables position Global.promptInt(" player position:")

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

Database Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions

Question

Question What is a Roth 401(k) feature?

Answered: 1 week ago