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();
}
}
}
Java Program Name Final Part 2: Open Book 1. Define a Class called UFCFighter. a. Make...
in JAVA Which of the following attributes would be MOST appropriate for a class called Book, that represents a book in a library? libraryName, location, libraryHours title, author, typeOfBook pages, cost, shipping anything, anytime, anywhere Which of the following statements is FALSE regarding constructors? A constructor allows you to set up an object once it is instantiated. A constructor does not have a return type. A constructor must have the same name as the name of the class. You can...
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...
JAVA PROGRAMMING In this final review lab from our intro course, use the Name class you created in the previous lab. In this lab, create a Student class with the following class variable: Student name: Name (Note: Name is a datatype) Student Id: String Create the getter and setter methods. In addition to these methods, create a toString() method, which overrides the object class toString() method. This override method prints the current value of any of this class object. Complete...
Suppose you were given the job to write a Java class to manage employee payroll information in an HR management system. Each employee will be modeled as a single EmployeePayroll object (much like the Student objects discussed in class). The state of the EmployeePayroll object includes the first name and last name of the employee, a unique 15 digit employee number for each employee, a number of hours that they've worked this week (which could be a fraction of an...
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 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. 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...
Lab 1: InheritanceTest Write a program called InheritanceTest1.java to support an inheritance hierarchy for class Point–Square–Cube. Use Point as the superclass of the hierarchy. Specify the instance variables and methods for each class. The private data of Point should be the x-y coordinates, the private data of Square should be the sideLength, and the private data of Cube should be depth. Provide applicable accessor methods, mutator methods, toString() methods, area() method, and volume() method to all classes. Write a program...
(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...
Java Project For this assignment, you will 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 instead include a single add method...