0% found this document useful (0 votes)
18 views2 pages

Concrete Class Exercise

The document describes creating a TennisPlayer class with attributes to represent a tennis player (surname, world ranking, gender, age, weeks) and methods to get/set these attributes. It also includes a winPercentage method that returns the player's chance of winning a match based on their and their opponent's world ranking and how many weeks it has been since the player's last win. The class is to be implemented according to UML and Java coding standards provided in the tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Concrete Class Exercise

The document describes creating a TennisPlayer class with attributes to represent a tennis player (surname, world ranking, gender, age, weeks) and methods to get/set these attributes. It also includes a winPercentage method that returns the player's chance of winning a match based on their and their opponent's world ranking and how many weeks it has been since the player's last win. The class is to be implemented according to UML and Java coding standards provided in the tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise (Create a Concrete Class):

Preparation:
1. Create an application folder in the D drive called “D:\My Documents\StudentNumber\Exercise\”, where StudentNumber
is your actual student number.
2. Create a new file in Notepad++ called Open the “TennisPlayer.java” file in NotePad++ and complete the question as
instructed below.

The question:
Write a Java concrete class named TennisPlayer that can be used to present a tennis player and to determine the win percentage of
the player before he/she plays a tennis match. Complete the TennisPlayer class as described in the UML class diagram (Table 1.1)
and description (Table 1.2) below.

TennisPlayer
- surname: String
- worldRanking: int
- gender: char
- age: int
- weeks: int
+ TennisPlayer()
+ TennisPlayer(String, int, char, int, int)
+ setSurname(String): void
+ setWorldRankings(int): void
+ setGender(char): void
+ setAge(int): void
+ setWeeks(int): void
+ getSurname(): String
+ getWorldRankings(): int
+ getGender(): char
+ getAge(): int
+ getWeeks(): int
+ winPercentage(int): double
Table 1.1: UML Class Diagram (TennisPlayer)
Attribute/Method Description Marks
surname These are all instance data members that is used to describe a tennis player. A tennis player will have
worldRanking a surname, must have a world ranking (worldRanking), is either a male or female (gender), has an
gender age, and must know how many weeks it has been since his/her last won a match. 4
age
weeks
TennisPlayer() The default constructor will assign the default values of 100 and 10 to the data member’s
3
worldRanking and weeks respectively.
TennisPlayer(String, int, char, int, int) The overloaded parameterized constructor will receive the values to be assigned to the data
300
members as parameters.
setSurname(String) Mutator methods.
setWorldRankings(int)
setGender(char) 5
setAge(int)
setWeeks(int)
getSurname() Accessor methods.
getWorldRankings()
getGender() 5
getAge()
getWeeks()
winPercentage(int)  The method will be used to determine and return the winning percentage of
the tennis player before a tennis match.
This method will receive as parameter the world ranking of the opponent.
 The tennis player will have a 20% possibility of winning the match if he/she
has a world ranking higher than the opponent.
9
 The winning percentage increase a lot if the player’s world ranking is lower
than the opponent based on the form the player is currently in.
o If the number of weeks is more than 5 since the last time the player
won a game, the then winning percentage is 60%, otherwise the
winning percentage is 80%.
Table 1.2: Class Description (TennisPlayer)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy