make a code for this in java encapsulation and data hiding player class Step 1: Create a
Fantastic news! We've Found the answer you've been seeking!
Question:
make a code for this in java encapsulation and data hiding player class
Transcribed Image Text:
Step 1: Create a class 'Player'. • Step 2: Declare four (4X) fields/variables names as private: playerName as string, age as number, and gameType as string. • Step 3: Create four (4X) constructors with the following arguments: 1st constructor: playerName as string. 2nd constructor: age as number. 3nd constructor: playerName as string, age as number. • 4th constructor: playerName as string, age as number, and gameType as string. • Step 4: Create a public getter method for each private variable. • Step 5: Create a public setter method for each private variable and provide its argument. • Step 6: Create a test class Player Test. •Step 7: In main method, create four (4X) different objects of a class Player by instantiating with the use of new keyword: 1st object: obj1 passing the playerName "Player 1" 2nd object: obj2 passing the age 21 3rd object: obj3 passing the playerName "Player 2" and age 33 4th object: obj4 passing the playerName "Player 3", age 29, and gameType "Single Player" •Step 8: Call the setter method for playerName of obj1 and change its playerName to "Dave" ⚫ Step 9: Using System.out.println, call the getter method for playerName of obj1. This should print "Dave". • Step 10: Using System.out.println, call the getter method for age of obj2. This should print 21. • Step 11: Call the setter method for age of obj2 and change its age to 25 Step 12: Using System.out.println, call the getter method for age of obj2. This should print 25. • Step 13: Call the setter method for age of obj3 and change its age to 30 Step 14: Using System.out.println, call the getter method for age of obj3. This should print 30. • Step 15: Call the setter method for gameType of obj4 and change its gameType to "Multi Player". •Step 16: Using System.out.println, call the getter method for game Type of obj4. This should print "Multi Player". • Step 17: Using System.out.println, call the getter method for age of obj4. This should print 29. Step 1: Create a class 'Player'. • Step 2: Declare four (4X) fields/variables names as private: playerName as string, age as number, and gameType as string. • Step 3: Create four (4X) constructors with the following arguments: 1st constructor: playerName as string. 2nd constructor: age as number. 3nd constructor: playerName as string, age as number. • 4th constructor: playerName as string, age as number, and gameType as string. • Step 4: Create a public getter method for each private variable. • Step 5: Create a public setter method for each private variable and provide its argument. • Step 6: Create a test class Player Test. •Step 7: In main method, create four (4X) different objects of a class Player by instantiating with the use of new keyword: 1st object: obj1 passing the playerName "Player 1" 2nd object: obj2 passing the age 21 3rd object: obj3 passing the playerName "Player 2" and age 33 4th object: obj4 passing the playerName "Player 3", age 29, and gameType "Single Player" •Step 8: Call the setter method for playerName of obj1 and change its playerName to "Dave" ⚫ Step 9: Using System.out.println, call the getter method for playerName of obj1. This should print "Dave". • Step 10: Using System.out.println, call the getter method for age of obj2. This should print 21. • Step 11: Call the setter method for age of obj2 and change its age to 25 Step 12: Using System.out.println, call the getter method for age of obj2. This should print 25. • Step 13: Call the setter method for age of obj3 and change its age to 30 Step 14: Using System.out.println, call the getter method for age of obj3. This should print 30. • Step 15: Call the setter method for gameType of obj4 and change its gameType to "Multi Player". •Step 16: Using System.out.println, call the getter method for game Type of obj4. This should print "Multi Player". • Step 17: Using System.out.println, call the getter method for age of obj4. This should print 29.
Expert Answer:
Answer rating: 100% (QA)
Heres the code for the Player class including the constructors getter and setter methods java public ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
The fraud examiner's report should have what characteristics? a. Accuracy and clarity b. Relevant and material information c. Should not contain opinions or prejudices of fraud examiner. d. All of...
-
In its Summer 2013 Animal Action Report, the National Anti-Vivisection Society stated that "59% of Americans between the ages of 18 and 29 oppose medical testing on animals." The percentage of 59%...
-
You and your spouse are in good health and have reasonably secure careers. Each of you makes about $55,000 annually. You own a home with a mortgage of $120,000, and you owe $15,000 on car loans,...
-
A channel has a rectangular cross section, a width of \(40 \mathrm{~m}\), and a flow rate of \(4000 \mathrm{~m}^{3} / \mathrm{s}\). The normal water depth is \(20 \mathrm{~m}\). The flow then...
-
On January 1, 2015, Geffrey Corporation had the following stockholders equity accounts. Common Stock ($20 par value, 60,000 shares issued and outstanding) ...$1,200,000 Paid-in Capital in Excess of...
-
2. Write a program in python to get the number from the user using GUI. Use 2 command buttons one to check whether the number is an amstrong number If the given number is a amstrong, display it is a...
-
Emily practices the piano 826 minutes in 2 weeks. Assuming she practices the same amount every week, how many minutes would she practice in 3 weeks?
-
The assumption that people are complex with widely varying needs is most associated with the ____________ management approaches. (a) classical (b) neoclassical (c) behavioural (d) modern
-
Discuss the importance of ethics in the relationship between managers and the people they supervise.
-
Which is the correct match? (a) Folletanalytics (b) McGregormotion study (c) Demingquality management (d) MaslowTheory X and Y
-
The requirement that a manager answer to a higher-level boss for performance results achieved by a work team is called ____________. (a) dependency (b) accountability (c) authority (d) empowerment
-
In Katzs framework, top managers tend to rely more on their ____________ skills than do first-line managers. (a) human (b) conceptual (c) decision-making (d) technical
-
In your initial post, use these 5 categories to analyze one of the Becoming Academic narratives from Ch. 1: either Coatess Between the World and Me, Rodriguezs Scholarship Boy, or Graffs Disliking...
-
Determine the resultant moment produced by the forces about point O. 0.25 m 0.125 m, 0 0.3 m- 60 F = 500 N F = 600 N
-
Quince Interests is a partnership with a tax year that ends September 30, 2012. During that year, Potter, a partner, received $3,000 per month as a guaranteed payment, and his share of partnership...
-
During 2012, Palo Fiero purchases the following property for use in his manufacturing business: Palo uses the accelerated depreciation method under MACRS, if available, and does not make the election...
-
Van makes an investment in a partnership in 2012. Van's capital contributions to the partnership consisted of $30,000 cash and a building with an adjusted basis of$70,000, subject to a nonrecourse...
-
The two key qualities of accounting information are (according to the IASB): A. Prudence and verifiability. B. Representational faithfulness and reliability. C. Representational faithfulness and...
-
The accrual basis is that: A. Cash transactions should not be accounted for. B. Only cash transactions should be accounted for. C. Income and expenses should be accounted for as cash inflows and...
-
On the issue of going concern in the context of IAS 1: A. Entities must be assumed to last no longer than 12 months. B. Entities can be assumed to last for 12 months, but accountants must not assume...
Study smarter with the SolutionInn App