MAX GROUP SIZE = 2 In honor of the Winter Olympics, our Projects this semester w
ID: 3707963 • Letter: M
Question
MAX GROUP SIZE = 2
In honor of the Winter Olympics, our Projects this semester will have a Winter Olympics theme. For Project #1, we'll be building, documenting and testing Objects and Enums that we will need to simulate our own Winter Olympics. The specification for our Objects, Enums and Driver is provided below. Also provided below are UML Diagrams depicting what our Objects should contain.
----------------------------------------------------------------------------------------
Athlete Object (Remember to consult the UML for attribute data types, method parameters and method return data types!):
Athletes should have:
A name attribute
A country attribute
A type of event attribute
A skill attribute
A counter for number of GOLD medals won (we will ignore silver and bronze medals for this version of the project)
A full parameter constructor (a constructor with a parameter for each of the 5 fields)
A default parameter constructor
A get method for each field
A set method for each field
Verify at least 1 character was entered for the name! If not, set the Athlete's name as DEFAULT.
Verify that skill entered is between 0 and 10! If not, set the Athlete's skill as 0.
Verify that gold medals entered is not negative! If value entered for medals is negative, set medals value to 0.
A toString() method
An equals() method
MAKE SURE YOU HAVE JAVADOC COMMENTS FOR THE CLASS AND THE METHODS!!!
Class Level JavaDoc comments need AT LEAST:
The author(s) tag(s)
A description about what this class/object is for
Method Level JavaDoc comments need AT LEAST:
A description of what the method does
param tag(s) describing the input data if the method needs input data
return tag describing the returned output data if the method returns data
-----------------------------------------------------------------------------------------------
Event Object (Remember to consult the UML for attribute data types, method parameters and method return data types!):
Events should have:
A specific event name attribute
A venue attribute
A type of event attribute
A list of Athletes attribute
A full parameter constructor (a constructor with a parameter for each of the 4 fields)
A default parameter constructor
A get method for each field
A set method for each field
Verify that list of Athletes attribute has at least 1 Athlete! Otherwise, print an error message saying that competitions need at least 1 Athlete in order to run.
A toString() method
An equals() method
A compete() method which calculates the winning Athlete. This method should work by looping through the list of Athletes and, for each Athlete, generating a random number from 1 to 100 (both values inclusive) and adding the Athlete's skill attribute to the random number. The Athlete with the greatest sum (random value + Athlete's skill) is the winner of the event.
MAKE SURE YOU HAVE JAVADOC COMMENTS FOR THE CLASS AND THE METHODS!!!
Class Level JavaDoc comments need AT LEAST:
The author(s) tag(s)
A description about what this class/object is for
Method Level JavaDoc comments need AT LEAST:
A description of what the method does
param tag(s) describing the input data if the method needs input data
return tag describing the returned output data if the method returns data
-----------------------------------------------------------------------------------------------
Country Enum:
Must include a default value and AT LEAST 10 countries from this list --> https://www.pyeongchang2018.com/en/countries
Must include a method which returns a randomly selected Country Enum value
-----------------------------------------------------------------------------------------------
EventType Enum:
Must include a default value and all 15 general events listed here --> https://www.pyeongchang2018.com/en/game-time/results/OWG2018/en/general/competition-schedule.htm
Must include a method which returns a randomly selected EventType Enum value
-----------------------------------------------------------------------------------------------
Venue Enum:
Must include a default value and all 13 venues listed here --> https://www.pyeongchang2018.com/en/venues
Must include a method which returns a randomly selected Venue Enum value
-----------------------------------------------------------------------------------------------
The Driver:
The Driver Class will need:
A main() method which will:
Randomly select 5 event types.
Create 3 Athletes for each of the 5 selected event types. Data for each Athlete should be generated by:
Hardcoded name data
Randomly selected country data
event type data as per the 5 event types selected at the beginning
Randomly selected skill data (from 1 to 10, both values inclusive)
Medal count data should start at zero
Create 1 event for each of the 5 selected event types. Data for each Event should be generated by:
Hardcoded name data
Randomly selected venue data
event type data as per the 5 event types selected at the beginning
Use an array of the Athletes you created with the the same event type attribute
For each Event, use the compete() method to determine the winning Athlete AND print the winning Athlete's information along with the name of the Event that the Athlete won.
Also include code to test any other methods from Athlete and Event which the above main() method code did not test.
You may add additional attributes and/or methods to Athlete, Event, and your Driver if they will help you solve the problem.
------------------------------------------------------------------------------------------------------------------------------
POINT BREAKDOWN:
Correct and Complete Country Enum (5 Points)
1 Points for Enum structure/file
2 Points for the correct values
2 points for the functioning random generator
Correct and Complete EventType Enum (5 Points)
1 Points for Enum structure/file
2 Points for the correct values
2 points for the functioning random generator
Correct and Complete Venue Enum (5 Points)
1 Points for Enum structure/file
2 Points for the correct values
2 points for the functioning random generator
Correct and Complete Athlete Object (20 points)
2 Points for Attributes
3 Points for Set Methods
3 Points for Get Methods
3 Points for Default Constructor
3 Points for Full Parameter Constructor
3 Points for equals() method
3 Points for toString() method
Correct and Complete Event Object (25 points)
2 Points for Attributes
3 Points for Set Methods
3 Points for Get Methods
3 Points for Default Constructor
3 Points for Full Parameter Constructor
3 Points for equals() method
3 Points for toString() method
5 Points for the compete() method
Correct and Complete Driver (25 Points)
5 Points for correctly creating the Athletes
5 Points for correctly creating the Events
5 Points for correctly handling the compete() calls out output printing
10 Points for all other driver logic (including ensuring all Object methods have been tested!)
Correct and Complete JavaDoc comments (15 Points)
Explanation / Answer
I have mae your work easy. Just review the class below and make the changes. You can write Drive method by yourself, as time doesn't permit to complete the code.
class Athelete
{
private String name;
private String country;
private String typeOfEvent;
private int skill;
private int goldCount;
public Athelete(String name, String country, String typeOfEvent, int skill, int goldCount) {
this.name = name;
this.country = country;
this.typeOfEvent = typeOfEvent;
this.skill = skill;
this.goldCount=goldCount;
}
public String getName() {
return name;
}
public void setName(String name) {
if(name.length()>0)
this.name = name;
else
this.name="Dhoni";
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getTypeOfEvent() {
return typeOfEvent;
}
public void setTypeOfEvent(String typeOfEvent) {
this.typeOfEvent = typeOfEvent;
}
public int getSkill() {
return skill;
}
public void setSkill(int skill) {
if(skill>=0 && skill<=10)
this.skill = skill;
else
this.skill=0;
}
public int getGoldCount() {
return goldCount;
}
public void setGoldCount(int goldCount) {
if(goldCount>0)
this.goldCount = goldCount;
else
this.goldCount=0;
}
?
@Override
public String toString() {
return this.name+" "+"Country"+country+" Gold "+goldCount;
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
if(obj instanceof Athelete)
{
Athelete ath=(Athelete)obj;
if(ath.getName().equals(this.name))
return true;
}
return false;
}
}
class Event
{
private String eventName;
private String venue;
private String eventType;
private List<Athelete> atheleteList;
public Event(String eventName, String venue, String eventType, List<Athelete> atheleteList) {
this.eventName = eventName;
this.venue = venue;
this.eventType = eventType;
this.atheleteList = atheleteList;
}
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public String getVenue() {
return venue;
}
public void setVenue(String venue) {
this.venue = venue;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public List<Athelete> getAtheleteList() {
return atheleteList;
}
public void setAtheleteList(List<Athelete> atheleteList) {
try {
if(atheleteList.size()>0)
this.atheleteList = atheleteList;
else
throw new CustomException("competitions need at least 1 Athlete in order to run.");
}
catch(CustomException e)
{
e.getMessage();
}
}
private void compplete() {
Random r=new Random();
int max=0;
for(int i=0;i<atheleteList.size();i++)
{
int num=1+r.nextInt(100);
max=Math.max(num+atheleteList.get(i).getSkill(), max);
}
System.out.println(max);
}
?
}
class CustomException extends Exception
{
public CustomException(String mess) {
super(mess);
}
}
enum Country
{
India, Australia, USA;
private static final List<Country> VALUES =
Collections.unmodifiableList(Arrays.asList(values()));
private static final int SIZE = VALUES.size();
private static final Random RANDOM = new Random();
public static Country randomLetter() {
return VALUES.get(RANDOM.nextInt(SIZE));
}
}
enum EventType
{
// Implement similarly as I have done for the country
}
enum VenueEnum
{
// Implement similarly as I have done for the country
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.