A user can add tetriminos into the middle band tocreate a


Write a Java application called NewTetristhat allows a new way to play Tetris. It is well known that in Tetris there are seven kinds of tetriminos, each of which is made up of four minos.The application window is divided into three bands: top, middle and bottom. When the application starts, seven different tetriminos will appear within the top band, as shown in the Java applet below. These seven tetrinimos are referred to as model tetriminos. A user can add tetriminos into the middle band tocreate a meaningful shape. A tetrimino that is no longer useful can be deleted byputting it into the bottom band.

Specifically, a user can perform the following four operations to create a meaningful shape in the middle band.

  • Add: to add a tetrimino, a user can use the left mouse button to drag the corresponding model tetrimino located within the top band. When a model tetrimino is selected to be dragged, a duplicate is made out of the model. It is the duplicate that is actually dragged. The model tetrimino stays at the same location.

  • Move: To move a duplicate tetrimino, use the left mouse button to drag it. The model tetrimino can't be moved.

  • Rotate: To rotate a duplicate tetrimino, use the right mouse button to click one of its four minos. Please note the tetrimino will rotate about the center of the mino that is clicked. The model tetrimino can't be rotated.

  • Delete: at the end of the moving or rotating operation, if the tetrimino intersects with the bottom band, the tetrimino will be deleted. Since a model tetrimino can't be moved or rotated, it can't be deleted.

     

    Requirements/Recommendations:

    • You shall write a class named CMino to describe a mino.

    • You shall write a class named CTetriMino to describe seven different tetriminos.

    • You can use collections to keep a record of all the tetriminos added so far.

    • Use event handlers to add, move, rotate and delete a tetrimino.

    • After rotating a point (x1, y1) about another point (x0, y0) counterclockwise through an angle of theta in radians, its new location (x2, y2) can be represented as follows.

      • x2=x0+(x1-x0)*cos(theta)-(y1-y0)*sin(theta)

      • y2=y0+(x1-x0)*sin(theta)+(y1-y0)*cos(theta)

 

Next:

Extend the NewTetris application completed in Project #2 to be a two-user network application that allows two users on two different machines to play the NewTetris game together. Both users have their own application windows on their own machines. Whatever one user has performed an operation within his/her window will be immediately reflected on the window of the other user too. Therefore both windows will show exactly the same tetrimino collection.

Difficulty: this is a typical distributed computing project. The difficulty is how to handle the conflicting operations simultaneously performed by the two users. For example, what to do when two users want to drag the same tetrimino at the same time? At the minimum, you can assume that the users will make sure no conflicting operations will be performed by themselves. If you choose to implement an advanced solution, please describe your idea in the email message body. Up to ten (10) bonus points will be awarded if you have successfully implemented an advanced solution to the conflicting operation problem.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: A user can add tetriminos into the middle band tocreate a
Reference No:- TGS0645747

Expected delivery within 24 Hours