Suppose that you are in change of customer service for a certain business. As phone calls come in, the name of the caller is recorded and eventually a service representative returns the call and handles the request. Write a class ServiceRequests that keeps track of the names of callers. The class should have the following methods:
- addName (name)—adds a name to the list of names. Throws a ServiceBackUpException if there is no free space in the list
- removeName (name)—removes a name from the list Throws a NoServiceRequestException if the name is not in the list.
- getName (i)—returns the ith name in the 1st.
- getNumber—returns the current number of service requests.
Write a program that uses an object of type ServiceRequests to keep track of customers that have called. It should have a loop that, in each iteration, attempts to add a name, remove a name, or print all names. Use an array of size 10 as the list of names.
Graphics
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Additional Engineering Textbook Solutions
Database Concepts (7th Edition)
Introduction to Programming Using Visual Basic (10th Edition)
Programming in C
Starting Out with Python (3rd Edition)
C How to Program (8th Edition)
Starting Out with Python (4th Edition)
- Fibonacci A fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers. For example: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on… For this, you will implement a class that takes a positive integer (n) and returns the number in the nth position in the sequence. Examples When n is 1, the returned value will be 0. When n is 4, the returned value will be 2. When n is 9, the returned value will be 21. come up with the formula and base cases Implementation Create a class Fibonacci with a public static method getValue. Create a Main class to test and run your Fibonacci class.arrow_forwardWrite the source code of the class Passenger. A passenger can travel with an infant (i.e. his/her child). Code the class Infant as an inner class of the class Passenger. If a passenger is not travelling with an infant, the getInfantMonths method must return –1.arrow_forwardComputer Science You are required to develop a small chatting application where two or more friends can communicate each other through messages. Create a class Message which has Date d, and message (string). Provide getters/setters, constructors, toString. Create a class Friend having String name, String contact, email and ArrayList of Messages provide getters/setters, constructors, toString addMessage(Message m) method which will add new message to the list. Provide following options to the user using JFrame. Login which will help user login to the application. View Friends (Display List of All Friends) View Messages ( This should display all message of a Friend) Send message (This should ask for friend name and message match the friend name and write that message to the array list).arrow_forward
- //Todo write test cases for SimpleCalculator Class // No need to implement the actual Calculator class just write Test cases as per TDD. // you need to just write test cases no mocking // test should cover all methods from calculator and all scenarios, so a minimum of 5 test // 1 for add, 1 for subtract, 1 for multiply, 2 for divide (1 for normal division, 1 for division by 0) // make sure all these test cases fail public class CalculatorTest { //Declare variable here private Calculator calculator; //Add before each here //write test cases here }arrow_forwardSuppose a class GroceryBill keeps track of a list of items being purchased at a market: Method/Constructor Description constructs a GroceryBill object for the given clerk public GroceryBill(Employee clerk) public void add(Item i) public double getTotal() public void printReceipt(0 adds i to this bill's total returns the cost of these items prints a list of items GroceryBill objects interact with Item objects. An Item has the following public methods: Method/Constructor Description returns the price for this item public double getDiscount() returns the discount for this item public double getPrice() For example, a candy bar item might cost 1.35 with a discount of 0.25 for preferred customers, meaning that preferred customers get it for 1.10. (Some items will have no discount, 0.0.) Currently the above classes do not consider discounts. Every item in a bill is charged full price, and item discounts are ignored. Define a class DiscountBill that extends GroceryBill to compute discounts for…arrow_forward⚫ Task 1: Create a Class Tasks Define a class named Person with attributes name and age. Write a method greet() that prints a greeting message including the person's name and age. ⚫ Task 2: Rectangle Class Create a class Rectangle that takes length and width as parameters. Add methods area() and perimeter() to calculate and return the area and perimeter of the rectangle. ⚫ Task 3: Object Interaction Create a Library dass that contains a list of books and methods to add, remove, and list all books in the library. • Task 4: Movie Class Create a class Movie with attributes title, director, and rating. Add a method display_info() that prints the movie's details and a method rate_movie (new_rating) to update the movie's rating. • Task 5: Ticket Class (homework) Define a class Ticket' with attributes event_name, date, and `price. Add methods apply_discount(discount_percentage) to reduce the price by a given percentage and display_ticket()` to print the ticket details including the final…arrow_forward
- Add a removeLot method to the Auction class, having the -following header: /** * Remove the lot with the given lot number. * @param number The number of the lot to be removed. * @return The Lot with the given number, or null if * there is no such lot. */ public Lot removeLot(int number) This method should not assume that alot with a given number is stored at any particular location within the collection.arrow_forwardThe play method in the Player class of the craps game plays an entire game without interaction with the user. Revise the Player class so that its user can make individual rolls of the dice and view the results after each roll. The Player class no longer accumulates a list of rolls, but saves the string representation of each roll after it is made. Add new methods rollDice, getNumberOfRolls, isWinner, and isLoser to the Player class. The last three methods allow the user to obtain the number of rolls and to determine whether there is a winner or a loser. The last two methods are associated with new Boolean instance variables (winner and loser respectively). Two other instance variables track the number of rolls and the string representation of the most recent roll (rollsCount and roll). Another instance variable (atStartup) tracks whether or not the first roll has occurred. At instantiation, the roll, rollsCount, atStartup, winner, and loser variables are set to their appropriate…arrow_forward3. Write a class Student having attributes to store the following data: Name, fathers’ Name, department, degree, enrolment, seat number, marks of three subjects. Also write a class to test all methods of Student class. Add the following methods in the above class. • int getTotal() : This methods returns the total of marks • void printTotal() Prints the total marks of Student • float getPercentage() this method calculates the percentage of a student • void printPercentatge() this method prints the percentage of student • char getGrade() this method calculates and returns the grade. • void printGrade() this method prints the grade of a student. • void printInfo() This method prints all information of the student.arrow_forward
- ⚫ Task 1: Create a Class Tasks Define a class named Person with attributes name and age. Write a method greet() that prints a greeting message including the person's name and age. ⚫ Task 2: Rectangle Class Create a class Rectangle that takes length and width as parameters. Add methods area() and perimeter() to calculate and return the area and perimeter of the rectangle. ⚫ Task 3: Object Interaction Create a Library class that contains a list of books and methods to add, remove, and list all books in the library. • Task 4: Movie Class Create a class Movie with attributes title, director, and rating. Add a method display_info() that prints the movie's details and a method rate_movie(new_rating) to update the movie's rating. • Task 5: Ticket Class(homework) Define a class Ticket' with attributes event_name, date, and price. Add methods apply_discount(discount_percentage) to reduce the price by a given percentage and display_ticket() to print the ticket details including the final price…arrow_forwardThe goal of this coding exercise is to create two classes BookstoreBook and LibraryBook. Both classes have these attributes: author: Stringtiltle: Stringisbn : String- The BookstoreBook has an additional data member to store the price of the book, and whether the book is on sale or not. If a bookstore book is on sale, we need to add the reduction percentage (like 20% off...etc). For a LibraryBook, we add the call number (that tells you where the book is in the library) as a string. The call number is automatically generated by the following procedure:The call number is a string with the format xx.yyy.c, where xx is the floor number that is randomly assigned (our library has 99 floors), yyy are the first three letters of the author’s name (we assume that all names are at least three letters long), and c is the last character of the isbn.- In each of the classes, add the setters, the getters, at least three constructors (of your choosing) and override the toString method (see samplerun…arrow_forwardA mountain climbing club maintains a record of the climbs that its members have made. Information about a climb includes the name of the mountain peak and the amount of time it took to reach the top. The information is contained in the ClimbInfo class as declared below. The ClimbingClub class maintains a list of the climbs made by members of the club. The declaration of the ClimbingClub class is shown below. You will write implementations of the addClimb method. import java.util.List; import java.util.ArrayList; class ClimbInfo { private String name; private int time; /** Creates a ClimbInfo object with name peakName and time climbTime. * * @param peakName the name of the mountain peak * @param climbTime the number of minutes taken to complete the climb */ public ClimbInfo(String peakName, int climbTime) { name = peakName; time = climbTime; } /** @return the name of the mountain peak */ public String getName() { return name; } /** @return the number of minutes…arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage