Question

there is a employee class and list made from it.Two subclasses are waiter and cook. How...

there is a employee class and list made from it.Two subclasses are waiter and cook. How can i add cook to the employee list in a method . and how can i randomly select a waiter and return it .This is in JAVA
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Use Multithreading in JAVA.

When you call AddCook(); in the Restaurant thread, it will wait(). And then nothing will happen anymore. The problem is, that you have only one thread, this one cannot notify itself. I think what you want to do is turn your Client, Waiter, and Chef into threads. Then start them one after another and then the Waiter has to wait until the Client made his order and the Chef has to wait until the Waiter got the order...

This is like "java producer-consumer example".

Add a comment
Know the answer?
Add Answer to:
there is a employee class and list made from it.Two subclasses are waiter and cook. How...
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
  • Java Programming Design a class named Person and its two subclasses named Student and Employee. A...

    Java Programming Design a class named Person and its two subclasses named Student and Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. Override the toString method in each class to display the class name and the person's name....

  • Define a class named Employee . Derive this class from the class Person. An employee record...

    Define a class named Employee . Derive this class from the class Person. An employee record inherits an employee's name from the class Person. In addition, an employee record contains an annual salary (represented by a single value of type double), a hire date that gives the year hired (as a single value of type int), an identification number of type int, and a department of type String. Give your class a reasonable complement of constructors, accessors, mutators, an equals...

  • In Java: Executable Class create an array of Employee objects. You can copy the array you...

    In Java: Executable Class create an array of Employee objects. You can copy the array you made for Chapter 20. create an ArrayList of Employee objects from that array. use an enhanced for loop to print all employees as shown in the sample output. create a TreeMap that uses Strings for keys and Employees as values. this TreeMap should map Employee ID numbers to their associated Employees. process the ArrayList to add elements to this map. print all employees in...

  • In C++ - Learn how to implement linked lists Part 1 Node and Linked List Class...

    In C++ - Learn how to implement linked lists Part 1 Node and Linked List Class (50 pts): Create node with public properties: Block type block and block ptr next. Create a linked list class that uses the node you generated without an add or delete method with a head and optional tail and counter. Make a driver that generates a node to test your implementation. Part 2 Add Method (30 pts): Create an add method in your linked list...

  • Assume Doctor Class is Following: class Doctor { private String fullName; private String registryNumber; private String...

    Assume Doctor Class is Following: class Doctor { private String fullName; private String registryNumber; private String specialty;    public Doctor(String fullName, String registryNumber, String specialty) { this.fullName = fullName; this.registryNumber = registryNumber; this.specialty = specialty; }    public String getName() { return fullName; }    public String getRegistryNumber() { return registryNumber; }    public String getSpecialty() { return specialty; }    public void setName(String fullName) { this.fullName = fullName; }    public boolean equals(Doctor other) { if(registryNumber == other.registryNumber) return...

  • In the Employee class, add an implementation for the calculatePension() method declared in the interface. Calculate...

    In the Employee class, add an implementation for the calculatePension() method declared in the interface. Calculate the pension to date as the equivalent of a monthly salary for every year in service. 4) Print the calculated pension for all employees. ************** I added the interface and I implemented the interface with Employee class but, I don't know how can i call the method in main class ************ import java.io.*; public class ManagerTest { public static void main(String[] args) { InputStreamReader...

  • Language : JAVA Part A Create a class CompanyDoc, representing an official document used by a...

    Language : JAVA Part A Create a class CompanyDoc, representing an official document used by a company. Give it a String title and an int length. Throughout the class, use the this. notation rather than bare instance variables and method calls.   Add a default constructor. Add a parameterized constructor that takes a value for title. Use this( appropriately to call one constructor from another. Add a toString(), which returns a string with the title, and the length in parentheses. So...

  • I want to write a superclass with one private attribute and one method in JAVA The super class wi...

    I want to write a superclass with one private attribute and one method in JAVA The super class will later derive into 2 subclasses each with its own private attributes and each with a method that OVERRIDES the superclass method with each subclasses with one method ( that will do something) unique to that subclass. ALL classes must have constructors initializing its attributes and getter/setter methods. Then, in the main method,  keep initializing objects of type superclasses based on user's...

  • Skip list, needs to be implemented in Java: - Implement the class NodeSkipList with two components,...

    Skip list, needs to be implemented in Java: - Implement the class NodeSkipList with two components, namely key node and array of successors. You can also add a constructor, but you do not need to add any method. - In the class SkipList implement a constructor SkipList(long maxNodes). The parameter maxNodes determines the maximal number of nodes that can be added to a skip list. Using this parameter we can determine the maximal height of a node, that is, the...

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
ADVERTISEMENT