Implement the following class in Java.
Class name: Cakes
Constructor Summary:
public Leaderboard() - Create a leaderboard with no entries, and current number of cakes eaten to 0.
Methods:
public List getContestants() - Return a list of all the contestant scores in the format (Name:Score). Return an empty list if no entries inside list.
Please provide a test to show your implementation works, thank you.
Solution:
code:
import java.util.ArrayList;
import java.util.List;
public class LeaderBoard {
List<String> name= new
ArrayList<String>();
int numberOfCakesEaten;
public LeaderBoard()
{
this.name= null;
this.numberOfCakesEaten= 0;
}
public List getContestants() //This is the
getContastants method
{
return this.name;
}
public static void main(String[] args) { //Driver
method
LeaderBoard lead= new
LeaderBoard();
System.out.println(lead.getContestants());
}
}
Output:

Hit the thumbs up if you liked the answer. :)
Implement the following class in Java. Class name: Cakes Constructor Summary: public Leaderboard() - Create a...
Implement the following class in Java: Class name: People Constructor Summary: public People (String name) Methods: public People(String name) public void setName(String name) public String getName() Class name: Truck Constructor Summary: public Truck (int licensePlate, int onBoard, People people) Initially, the truck does not contain any on board the vehicle. If the number of people on board the vehicle is a negative number, the value of onBoard should be stored as zero. Methods: public int getLicensePlate() Returns license plate of...
JAVA Create a Java project to implement a simple Name class. This class will have the following class variable: First Name, Middle Name, Last Name, and Full Name Create the accessor/getter and mutator/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. Create a main() method to test your project.
Create a public constructor (a method with the same name as the class) inside the class Fish. This constructor should take in no arguments. Inside the constructor, set typeOfFish to “Unknown” and friendliness to 3, which we are assuming is the generic friendliness of fish.
Create a LIFO class with following methods in java - public LifoList() The default constructor for LifoList class which will initialize your class variables maxSize to 0 and the int array to null. public LifoList(int maxSize) The constructor for LifoList class which takes the int input maxSize to initialize the size of the array. You should NOT reinitialize the array elsewhere. For example, creating an object as new LifoList(5) should create a LifoList whose maximum size is 5. If the...
Create a java class that implements BagInterface using singly linked data. Name this new class LinkedBag. Be sure to include a default constructor to initialize the private members of the class. Test that your code works properly. BagInterface includes the methods: public int getCurrentSize(); public boolean isEmpty(); public boolean add(T newEntry); public T remove(); public boolean remove(T anEntry); public void clear(); public int getFrequencyOf(T anEntry); public boolean contains(T anEntry); public T[] toArray();
Implement the following classes in the UML: 1. List class includes: constructor List(): Create an empty list with a length of 100. Hint: double [] list = new double [100]; constructor List(len: int): Create a List with a user specified maximum length. Hint: double [] list = new double [len]; add: add a new element to the end of the unsorted list. print: display the list 2.SortedList class includes two constructors : similar to the...
Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...
In Java. What would the methods of this class look like?
StackADT.java
public interface StackADT<T>
{
/** Adds one element to the top of this stack.
* @param element element to be pushed onto stack
*/
public void push (T element);
/** Removes and returns the top element from this stack.
* @return T element removed from the top of the stack
*/
public T pop();
/** Returns without removing the top element of this
stack.
* @return T...
(In Java) Implement a class named Student. For this exercise, a student has a name, an id number and a list of the quiz scores they have taken. Supply an appropriate constructor and methods getName(), getId(), addQuiz(int score), getTotalScore(), getNumQuizzes() and getAverageScore(). The scores should be stored in an array or ArrayList. You should compute the total score and the average score when needed. The id number should be implemented with the assistance of a static instance variable. The first...
Create a class called planet with private members name, percent02, temp. Create a constructor prototype and implementation. In the main, create 2 objects of class planet, one with arguments and the other without. Create a function to change name, percent02 and temp after the object has been created and a function that displays the current values of the members. Implement the operations specified above in the main of your program. This is all in C++, please help.