Fill This Form To Receive Instant Help
Homework answers / question archive / Write class called Hotel Building public interface Building {String address(); // return address that implements the interface shown below
Write class called Hotel Building public interface Building {String address(); // return address
that implements the interface shown below.
void newAddress(String s); // update address
)
use java code
1. Create a userdefined Thread class called MyClass that implements the Runnable Interface
2. Create three threads with thread names as Mercury, Venus and Earth
3. Execute the threads and sleep each thread for about 1000 ms
4. Write appropriate logic such that the next thread starts only after the previous thread has completed its execution
5. As each thread is started get its name and add it into an arraylist named "tact" which is declared in the MyClass class as follows and accessed from the run method to place the value.
public static ArrayList tact=new ArrayList();
6. The output of the program must be as follows
Sample Output
Mercury
Thread ended: Mercury
Venus
Thread ended: Venus
Earth
Thread ended: Earth
All three threads have finished execution
Requested files
JoinExample.java
Two friends are playing snake and ladder, can you help them to roll the dice specified number of times and return back the average value to indicate the value of the dice thrown so that they can move that many number of steps in the game.
Note:-
1. The userdefined Dice class must extend the Thread class
2. Create two threads for the two players by giving their player names as "Player 1" and "Player 2" and also indicate the number of times they will throw the dice in one go for each player and whose average of all the throws is the value of the movement.
For example,
Dice d = new Dice(6,"Player 1"); << Here 6 indicates 6 chances in a single run to roll the dice and average of the six rolls is the value that is indicated as steps to be moved in the game"
3. Randomize each roll from 1 to 6 for the indicated number of times the dice has to be rollled and then sum all the random value generated
4. For each player display "Average roll of Player 1 : 3" etc and add the same into an array list
Sample Output
Average roll of Player 1 : 4
Average roll of Player 2 : 2
Requested files
Dice.java