Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Assignment Two: Android, UML, and Design Patterns

COMPX202 (HAM), COMPX242 (HAM), and COMPX202 (TGA)

Due: Friday 22nd of September 11:59pm

Introduction

This assignment has three objectives:

1.   To interpret UML diagrams for Android development;

2.   To create a more advanced Android application;

3.   To experiment with a design pattern.

For this assignment, your goal is to develop an Android application that replicates the “ Find the Rainbow” game, as described below.

“ Find the Rainbow” is a simple Android-based game where the user is required to find and select a rainbow sprite (as shown in the included video). The game contains 20 purple, 20 blue, 20 green, 20 yellow, 20 red, and one rainbow sprite. When the game starts, all sprites are displayed in randomly generated locations on the gameboard, overlapping each other. The aim of the game is to locate (and select) the rainbow sprite. The user can click on the non-rainbow coloured sprites to remove them from the gameboard. The game is scored by subtracting one point for each non-rainbow sprite that is clicked. The score starts at 101, and the higher the final score, the better the user has done.

Resources required for completing this assignment to the specifications have been included on Moodle.

You  are  required  to  use  Git Lab  for  assignment  submission.  During  marking,  we  will  be looking  to  ensure  that  there  is  at  least  one  commit  for  each  major  addition  to  your application. Failure to do so will result in a reduction of marks even if the final application otherwise meets the specifications.

Note, if any of these instructions are unclear to you, you are expected to ask for clarification. Start the assignment early and make use of the labs for extra guidance and assistance.

Android Activities:

Your Application should include the following Android Activities:

●    MainActivity

   GameActivity

●    PlayerActivity

●    LeaderboardActivity

Appendix A shows the structure of the XML files, Appendix B shows screenshots of these Activities when displayed on a Pixel 4 emulator, and Appendix C contains the UML State  diagram showing the transitions between Activities.

Java Game Play:

Your application should also include the following Java classes:

●    GameState

●    Game

   Player

●    Sprite

●    Leaderboard

Appendix D shows the UML Class Diagram for these classes, while Appendix E contains some helpful code snippets.

Your task is to develop the “ Find the Rainbow” Android Application to match these

specifications and the UML diagrams included in the Appendices. Your solution will be

marked based on how closely it meets the requirements and UML diagrams, how well the  game play works, the quality of your commits, and the quality of your code. Make sure you structure and comment your code appropriately and take code quality (e.g. SOLID principles) into account.

Submitting

Make sure you have pushed all of your changes to your Git Lab repository. Ensure that you can see your changes on Git Lab. It is usually a good idea to clone the repository back to a new location on your local machine and re-run it to check that it was uploaded correctly.

Grading

 

Weighting

Allocated to

10%

Part A – Git Lab

20%

Part B – Activity user interfaces

20%

Part C – Activity functionality

40%

Part D – Game play

10%

Part I  – Code quality


Appendix A: XML Layout Diagrams (FYI, not UML notation)

(Full sized diagrams have been provided in the “COMPX202-242 Assignment #2 Resources” zip folder)

MainActivity


GameActivity




PlayerActivity

Leaderboard Activity


Appendix B: “ Find the Rainbow” application screenshots

Appendix C: UML State Diagram

(Full sized diagrams have been provided in the “COMPX202-242 Assignment #2 Resources” zip folder)

Appendix D: UML Class Diagram

(Full sized diagrams have been provided in the “COMPX202-242 Assignment #2 Resources” zip folder)

Appendix E: Helpful Android Code Snippets

1.   It can be tough to get the height and width of the Constraint Layout that will be used    as the gameboard. This is because you have to wait until Android has displayed it on the screen before it has a height and width. The code snippet below will let you get    the height and width after the Constraint Layout has been fully displayed. Pop this in   the onCreate method of your GameActivity.

ConstraintLayout gameboard = findViewById(R.id.cl_gameboard);

ViewTreeObserver vto = gameboard.getViewTreeObserver ();

vto.addOnGlobalLayoutListener (new

ViewTreeObserver.OnGlobalLayoutListener () {

@Override

public void onGlobalLayout() {

gameboard.getViewTreeObserver ().removeOnGlobalLayoutListener (this);

int boardWidth  = gameboard.getMeasuredWidth();

int boardHeight = gameboard.getMeasuredHeight();

// todo something

}

});

2.   So far, when getting access to Views and Resources from Java, we have used

findViewById() and get Resources(). These methods work inside Activity classes,    because the Activity knows which context it’s inside of. But, this won’t work from     inside a standard Java class – because the standard Java class doesn’t know the  context. The code snippets below can be used inside standard Java classes to get access to Views and Resources.

 ((Activity)context).findViewById(R.id.id_name)

context.getResources () …

3.  You might want to remove an Activity from the stack so that it is not returned to when the back button is clicked. If this is the case, add the following to the Activity in the

Android Manifest.

android:noHistory=”true”

4.  You’ll need the Hex value for purple.

#6750A4