Lab 4 Pig Game with Fragments Solution

$30.00

Category:

Description

Purpose

 

This lab is designed to give you practice:

 

  • Using multiple activities

 

  • Using fragments to adapt your app to large and small screen sizes.

 

  • Giving multiple fragments access to a single object (an instance of your game class).

 

Part 1

 

Do the textbook exercises shown below:

 

  • 9-1, Test the Tip Calculator with fragments

 

  • 9-2, Create a new fragment

 

  • 9-3, Use the fragment manager

 

Upload a text file to Canvas in which you will report, for each exercise above, whether you:

 

  1. Followed all the steps shown in the book and successfully compiled and ran the program (where applicable).

 

  1. Loaded the completed solution, experimented with the code, and ran the program (where applicable).

 

  1. Read through the steps and inspected the relevant code listings without writing or running a program.

 

  1. Didn’t do any of the above.

 

Part 2: Pig Game, version 3

 

In this lab you will modify your app to use fragments. You will have two fragments:

 

  1. An opening screen that displays instructions and asks the players for their names. It will have a

“New Game” button that launches fragment 2.

 

  1. The UI for game-play (similar to the main activity in the previous lab). The up button on will take the user back to the opening screen.

 

 

 

 

 

 

 

The up button will only be needed when fragment 2 is displayed by itself in a separate activity.

 

In fragment 2, the player’s name for the current turn will need to be displayed. Fragment 2 will hold the game object.

 

On a small screen, in portrait orientation, only one of these two fragments will be displayed at a time, each in its own activity.

 

 

On a large screen, in portrait orientation the fragments will be displayed one above the other.

 

In landscape orientation, the fragments will be displayed side-by-side.

 

 

 

 

Extra Credit:

 

Include the following items, which you already had in previous versions of the Pig game:

 

  1. A menu

 

  1. An about dialog which is displayed by clicking the “About” item on the menu.

 

  1. A settings screen which is displayed by clicking the “Settings” item on the menu.

 

  1. Save activity state during rotation or when starting another app and then returning to the game.

 

The Settings and Menu fragments will always be displayed by themselves. You can put a menu on both fragments 1 and 2, or on just fragment 1.

 

 

Zip the project and upload it to Canvas.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


error: Content is protected !!