Question
Java Program
Name Final Part 2: Open Book 1. Define a Class called UFCFighter. a. Make instance variables for Name, Weight, Wins, and Loses(pick appropriate variable types). b. Create a static variable for TotalFights c. Create a default constructor that defaults name to No Name yet, and al other variables to 0 d. Create a constructor that has parameters that set the value for name and weight, and sets wins and loses to 0. e. Create accessor methods for all the Variables (treat methods for static variables appropriately). f. Create a method that increments Wins and TotalFights g. Create a method that increments Loses and Totalfights. h. Create a method that returns true if 2 fighters have the same name, weight, wins, and losses. Create a static void method that compares a fighters wins to their loses and prints out whether or not they have a winning record(higher number of wins) or a losing record (higher number of losses). i. j. Create a static method that prints out all information for a fighter. k. Create a static method that makes 2 UFC fighters fight each other. The one with the higher win/loss ratio will win. This will then increment wins and total fights for winner, and increment losses and total fights for the loser.
0 0
Add a comment Improve this question Transcribed image text
Answer #1


Since programming language is not give, assuming it to be Java
To indent code in eclipse , select code by pressing ctrl+a and then indent using ctrl+i
Please do rate the answer if it was helpful. Thank you

public class UFCFighter {
private String Name;
private double Weight;
private int Wins;
private int Loses;

static int TotalFights = 0;

public UFCFighter()
{
Name = "No Name yet";
Weight = 0;
Wins = 0;
Loses = 0;
}

public UFCFighter(String name1, double weight1)
{
Name = name1;
Weight = weight1;
Wins = 0;
Loses = 0;
}

public String getName() {
return Name;
}

public double getWeight() {
return Weight;
}

public int getWins() {
return Wins;
}

public int getLoses() {
return Loses;
}

public static int getTotalFights() {
return TotalFights;
}

public void incrementWins()
{
Wins++;
TotalFights++;
}

public void incrementLosses()
{
Loses++;
TotalFights++;
}

public boolean equals(UFCFighter other)
{
if(Name.equalsIgnoreCase(other.Name) &&
Weight == other.Weight &&
Wins == other.Wins &&
Loses == other.Loses)
return true;
else
return false;
}

public void printRecordType()
{
if(Wins > Loses)
System.out.println("Winning record");
else
System.out.println("Losing record");
}


public void print()
{
System.out.println("Name: " + Name);
System.out.printf("Weight: %.2f\n", Weight);
System.out.println("Wins: " + Wins);
System.out.println("Loses: " + Loses);
}

public void fight(UFCFighter other)
{
double ratio1 = 1.0 * Wins / Loses;
double ratio2 = 1.0 * other.Wins / other.Loses;

System.out.println("Fight: " + Name + " Vs " + other.Name);
if(ratio1 > ratio2)
{
incrementWins();
other.incrementLosses();
}
else
{
incrementLosses();
other.incrementWins();
}

}

}

Add a comment
Know the answer?
Add Answer to:
Java Program Name Final Part 2: Open Book 1. Define a Class called UFCFighter. a. Make...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • create a java class with the name Brick class: For this part of the assignment, you...

    create a java class with the name Brick class: For this part of the assignment, you will create a class that allows you to specify a colored brick that is capable of drawing itself given a specified Graphics object. Note that this is a regular Java class and does not extend the JApplet class. Your class should a constructor with the following signature: Identifier: Brick(int xPosition, int yPosition, int width, int height, Color color) Parameters: xPosition – an int representing...

  • About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which...

    About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which has private data members for name, age, gender, and height. You MUST use this pointer when any of the member functions are using the member variables. Implement a constructor that initializes the strings with an empty string, characters with a null character and the numbers with zero. Create getters and setters for each member variable. Ensure that you identify correctly which member functions should...

  • 1. Employees and overriding a class method The Java program (check below) utilizes a superclass named...

    1. Employees and overriding a class method The Java program (check below) utilizes a superclass named EmployeePerson (check below) and two derived classes, EmployeeManager (check below) and EmployeeStaff (check below), each of which extends the EmployeePerson class. The main program creates objects of type EmployeeManager and EmployeeStaff and prints those objects. Run the program, which prints manager data only using the EmployeePerson class' printInfo method. Modify the EmployeeStaff class to override the EmployeePerson class' printInfo method and print all the...

  • Read through the code of the class Player, noting it has two instance variables, name and rank, which are of type String and three further instance variables won, drew and lost which are of type int....

    Read through the code of the class Player, noting it has two instance variables, name and rank, which are of type String and three further instance variables won, drew and lost which are of type int. There is also an attribute of the class, points, which does not have a corresponding instance variable. Also note the constructor and methods of the class and what they do. TournamentAdmin class code: public class RankAdmin {    /**     * Constructor for objects of class...

  • (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates...

    (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates for an upcoming election. This program needs to allow the user to enter candidates and then record votes as they come in and then calculate results and determine the winner. This program will have three classes: Candidate, Results and ElectionApp Candidate Class: This class records the information for each candidate that is running for office. Instance variables: first name last name office they are...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

  • You will write a two-class Java program that implements the Game of 21. This is a...

    You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...

  • First, you will need to create the Creature class. Creatures have 2 member variables: a name,...

    First, you will need to create the Creature class. Creatures have 2 member variables: a name, and the number of gold coins that they are carrying. Write a constructor, getter functions for each member, and 2 other functions: - void addGoldCoins(int) adds gold coins to the Creature. - void identify() prints the Creature information. The following should run in main: Creature d{"dragon", 50}; d.addGoldCoins(10); d.identify(); // This prints: The dragon is carrying 60 gold coins. Second, you are going to...

  • Step 1 Develop the following class: Class Name: Bag Access Modifier: public Instance variables Name: name...

    Step 1 Develop the following class: Class Name: Bag Access Modifier: public Instance variables Name: name Access modifier: private Data Type: String Name: currentWeight Access modifier: private Data Type: double Name: maximumWeight Access modifier: private Data Type: double Constructors Name: Bag Access modifier: public Parameters: none (default constructor) Task: sets the value of the instance variable name to the empty string sets the value of the instance variable currentWeight to 0.0 sets the value of the instance variable maximumWeight to...

  • Exercise 1: Adding a Test Harness to the Person class To make it easier to test...

    Exercise 1: Adding a Test Harness to the Person class To make it easier to test code that you have written for a Java class you can add to that class a main method that acts as a "test harness". A test harness is a main method that includes calls to methods that you wish to test. For convention this main method is the last method of the class. If you have a test harness, you do not need to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT