Create a class named TennisGame that holds data about a single tennis game. The
class has six fields: the names of the two players, the integer final scores for the
players, and the String values of the final scores. Include a get method for each of
the six fields. Also include a set method that accepts two players’ names, and
another set method that accepts the two integer final score values. The integer final
score for a player is the number of points the player won during the game; this value
should be in the range of 0 through 4. If either of the set method parameters for a
score is not in the range of 0 through 4, assign 0 to both scores and assign “error” to
the String scores. If both players’ score parameters are 4, assign 0 to both scores
and “error” to the String scores. The String score values are set by the method that
sets the integer score values. The String final score for each player contains the
traditional names for points in tennis: love, 15, 30, 40, or game, respectively, for the
values 0 through 4. Create a subclass named DoublesTennisGame that includes two
additional fields for the names of the first two players’ partners. Include get methods
for the names. Override the parent class setNames() method to accept the names of
all four players. Write an application named DemoTennisGames that instantiates
several objects of each of these classes. Demonstrate that all the methods assign
correct values. Save the files as TennisGame.java, DoublesTennisGame.java,
and DemoTennisGames.java
สร้างคลาสชื่อเทนนิสที่มีข้อมูลเกี่ยวกับเกมเทนนิสที่เดียว
ชั้นมีหกสาขา: ชื่อของผู้เล่นทั้งสองคะแนนสุดท้ายจำนวนเต็มสำหรับ
ผู้เล่นและค่า String ของคะแนนสุดท้าย รวมถึงวิธีการที่ได้รับสำหรับแต่ละ
หกสาขา ยังรวมถึงวิธีการตั้งค่าที่ยอมรับชื่อผู้เล่นทั้งสอง 'และ
วิธีการตั้งค่าอื่นที่ยอมรับทั้งสองจำนวนเต็มค่าคะแนนสุดท้าย จำนวนเต็มสุดท้าย
คะแนนสำหรับผู้เล่นคือจำนวนของจุดที่ได้รับรางวัลผู้เล่นระหว่างเกม; ค่านี้
ควรจะอยู่ในช่วง 0 ถึง 4 หากทั้งสองวิธีการตั้งค่าพารามิเตอร์สำหรับ
คะแนนที่ได้จะไม่ได้อยู่ในช่วง 0 ถึง 4 กำหนด 0 คะแนนทั้งสองและกำหนด "ข้อผิดพลาด" เพื่อ
คะแนนสตริง ถ้าพารามิเตอร์คะแนนผู้เล่นทั้งสองมี 4 กำหนด 0 คะแนนทั้งสอง
และ "ข้อผิดพลาด" เพื่อคะแนนสตริง ค่าคะแนน String ถูกกำหนดโดยวิธีการที่
กำหนดค่าคะแนนจำนวนเต็ม String คะแนนสุดท้ายสำหรับผู้เล่นแต่ละคนมี
ชื่อดั้งเดิมสำหรับจุดในเทนนิส: love, 15, 30, 40, หรือเกมตามลำดับสำหรับ
ค่า 0 ถึง 4 สร้าง subclass ชื่อ DoublesTennisGame ที่มีสอง
เขตข้อมูลเพิ่มเติมสำหรับชื่อของ เป็นครั้งแรกที่สองคู่ของผู้เล่น รวมถึงวิธีการได้รับ
ชื่อ แทนที่ setNames ระดับผู้ปกครอง () วิธีการที่จะยอมรับชื่อของ
ทั้งสี่ผู้เล่น เขียนชื่อแอปพลิเค DemoTennisGames ที่ instantiates
วัตถุหลายของแต่ละชั้นเรียนเหล่านี้ แสดงให้เห็นว่าวิธีการทั้งหมดกำหนด
ค่าที่ถูกต้อง บันทึกไฟล์เป็น TennisGame.java, DoublesTennisGame.java,
และ DemoTennisGames.java
การแปล กรุณารอสักครู่..

สร้างคลาสชื่อ tennisgame ที่เก็บข้อมูลเกี่ยวกับเกมเทนนิสเดี่ยว
ชั้นมี 6 สาขา : ชื่อของผู้เล่นสองคน , จำนวนเต็มสุดท้ายคะแนนสำหรับ
ผู้เล่นและสตริงค่าของคะแนนสุดท้าย รวมถึงได้รับวิธีการสำหรับแต่ละ
6 สาขา ยังรวมถึงชุดวิธีที่ยอมรับชื่อของผู้เล่นทั้งสองและวิธีการที่ยอมรับ
อีกชุดสองจำนวนเต็มคะแนนสุดท้ายค่าจำนวนเต็มสุดท้าย
คะแนนสำหรับผู้เล่นเป็นจำนวนของจุดที่ผู้เล่นจะในระหว่างเกม นี้ค่า
ควรอยู่ในช่วง 0 ถึง 4 . ถ้าชุดวิธีพารามิเตอร์สำหรับ
คะแนนไม่อยู่ในช่วง 0 ถึง 4 กำหนด 0 ทั้งคะแนน และมอบหมายให้ " ข้อผิดพลาด "
สายคะแนน ถ้าผู้เล่นทั้งคะแนนค่า 4 กำหนด 0 ทั้งคะแนน
" ข้อผิดพลาด " กับสตริงที่คะแนนสตริงคะแนนค่าถูกกำหนดโดยวิธีการที่
ชุดคะแนนเต็มค่า สายสุดท้ายคะแนนผู้เล่นแต่ละประกอบด้วย
ชื่อดั้งเดิมสำหรับจุดในเทนนิส : ความรัก , 15 , 30 , 40 หรือเกมตามลำดับสำหรับค่า
0 ถึง 4 สร้างคลาสชื่อ doublestennisgame ที่ประกอบด้วยสองเขตข้อมูลเพิ่มเติมสำหรับ
ชื่อของคู่ค้าสองผู้เล่นแรก รวมเอาวิธีการ
สำหรับชื่อ ยกเลิก setnames() เรียนผู้ปกครองวิธีการรับชื่อ
ผู้เล่นทั้งหมด 4 คน เขียนโปรแกรมชื่อ demotennisgames ที่ instantiates
หลายวัตถุของแต่ละชั้นเรียนเหล่านี้ แสดงให้เห็นว่าทุกวิธีกำหนด
ค่าถูกต้อง บันทึกไฟล์เป็น tennisgame.java doublestennisgame , Java , และ demotennisgames.java
.
การแปล กรุณารอสักครู่..
