Difference between revisions of "CISC181 S2017 Lab10"

From class_wiki
Jump to: navigation, search
(Created page with "===Preliminaries=== * Make a new '''Android''' project with ''n'' = 10 following these instructions through step 6. On step 7 "S...")
 
(Submission)
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
===Preliminaries===
 
===Preliminaries===
  
* Make a new '''Android''' project with ''n'' = 10 following [[CISC181_S2017_NewAndroidStudioProject | these ]] instructions through step 6.  On step 7 "Select form factor...", switch over to step 4 on the Android developers page tutorial  [https://developer.android.com/training/basics/firstapp/creating-project.html here] and complete through step 6 which ends with "...click '''Finish'''".  Make the default activity be called "StartActivity".
+
* Make a new '''Android''' project with ''n'' = 10 following [[CISC181_S2017_NewAndroidStudioProject | these ]] instructions through step 6.  On step 7 "Select form factor...", switch over to step 4 on the Android developers page tutorial  [https://developer.android.com/training/basics/firstapp/creating-project.html here] and complete through step 6 which ends with "...click '''Finish'''".  Make the default activity be called "StartActivity" (see below -- you will add two more).
  
 
===Instructions===
 
===Instructions===
  
You will create a simple trivial quiz Android app.  The app will have 3 ''activities'': <tt>StartActivity</tt>, <tt>QuestionActivity</tt>, and <tt>ScoreActivity</tt> that work together in the following way:  
+
You will create a simple trivial quiz game Android app.  The app will have 3 ''activities'': <tt>StartActivity</tt>, <tt>QuestionActivity</tt>, and <tt>ScoreActivity</tt> that work together in the following way:  
  
Second, take the empty activity project and modify it to become a very simple "rock paper scissors" generator as detailed below:
+
* '''<tt>StartActivity</tt>'''
 +
** This is the title screen, so you should print your game's name and its author (you) here
 +
** There are two options: number of questions (either 5 or 10), and answer type (multiple choice vs. free response)
 +
** A button to start the game.  This should start the <tt>QuestionActivity</tt>, with the option values added to the <tt>Intent</tt> as extras
 +
** A button to quit
 +
* '''<tt>QuestionActivity</tt>'''
 +
** Here you will progress through the number of questions indicated in the <tt>Intent</tt> that started the activity, and display them in the format chosen by the user
 +
*** If the answer type option is multiple choice, the choices are shown in a <tt>ListView</tt> beneath the question and the user clicks one to pick it
 +
*** If the option is free response, the answers are not shown and the user must type a string into an <tt>EditText</tt> view.  Just eliminate capitalization and don't worry about spelling errors before doing a string comparison
 +
** After each answer is given, use a <tt>Toast</tt> to tell the user if they are right or wrong, and go on to the next question
 +
** After the last question is answered, automatically start the <tt>ScoreActivity</tt>.  Pass the total number of questions and the number of correct answers as extras in the <tt>Intent</tt>
 +
* '''<tt>ScoreActivity</tt>'''
 +
** Report the user's score and, based on their percentage correct, write an appropriate evaluation message (e.g., "Wow, 100%!  You are smart!" or "Hmmm...you need to study more")
 +
** Have a button to take the user back to the <tt>StartActivity</tt>
  
# Change the layout in <tt>activity_my.xml</tt> to a vertical <tt>LinearLayout</tt>, similar to [http://developer.android.com/guide/topics/ui/layout/linear.html this example]
+
You will need an external file to store at least 20 questions and 2-4 possible answers per questionThis should be read by your program and turned into a data structure that <tt>QuestionActivity</tt> can easily useThe 5 or 10 questions that you present to the user for a given quiz should be randomly chosen from the overall pool.
# Change the old <tt>TextView</tt> that was printing "Hello, world" to say "Click the button below to get a new shape".
 
# Add an <tt>ImageView</tt> underneath, centered laterally, that initially shows a rock, paper, OR scissors image.  Find your own for these, cropped and scaled to 250 x 250, and put them in <tt>res/drawable</tt> with the names "rock.png", "paper.png", and "scissors.png".  Here's some help for [http://developer.android.com/guide/topics/resources/drawable-resource.html drawable resources]
 
# Add a <tt>TextView</tt> underneath the image which acts as a caption, saying "Rock" if the image is a rock, "Paper" if it's paper, and "Scissors" if it's scissorsThe caption should be centered laterally. 
 
# Finally, add a centered <tt>Button</tt> under the captionThis button should be labeled "New" and when pressed causes another random selection which (possibly) changes the image and caption above .  The caption text should be set not through resources but instead by using <tt>setText()</tt> in <tt>MyActivity.java</tt>, and something similar should be done with the image.
 
  
''Note'': Do NOT make changes to any other XML resource file besides <tt>activity_my.xml</tt>.  
+
You can make up these questions yourself or find them online.  Here's [https://github.com/ComputerScienceHouse/trivia-bot/tree/master/questions a set I found] that you can grab to save time.
  
Here is a screenshot of a sample program that satisfies the above requirements (except it should say "MyLab_9"):
+
For simplicity, don't use images or other multimedia resources in your questions and/or answers.
 
 
[[Image:300px-Lab10.png]]<br>
 
  
 
===Submission===
 
===Submission===
  
Submit your <tt>MyActivity.java</tt> and <tt>activity_my.xml</tt>. Make sure your name is in both.  FYI, comments in XML files look like this:
+
Submit your entire project directory (code + resources) to Sakai. Please zip or tar it before submission.
 
 
<nowiki>
 
<!-- here is my name -->
 
</nowiki>
 

Latest revision as of 20:23, 1 May 2017

Preliminaries

  • Make a new Android project with n = 10 following these instructions through step 6. On step 7 "Select form factor...", switch over to step 4 on the Android developers page tutorial here and complete through step 6 which ends with "...click Finish". Make the default activity be called "StartActivity" (see below -- you will add two more).

Instructions

You will create a simple trivial quiz game Android app. The app will have 3 activities: StartActivity, QuestionActivity, and ScoreActivity that work together in the following way:

  • StartActivity
    • This is the title screen, so you should print your game's name and its author (you) here
    • There are two options: number of questions (either 5 or 10), and answer type (multiple choice vs. free response)
    • A button to start the game. This should start the QuestionActivity, with the option values added to the Intent as extras
    • A button to quit
  • QuestionActivity
    • Here you will progress through the number of questions indicated in the Intent that started the activity, and display them in the format chosen by the user
      • If the answer type option is multiple choice, the choices are shown in a ListView beneath the question and the user clicks one to pick it
      • If the option is free response, the answers are not shown and the user must type a string into an EditText view. Just eliminate capitalization and don't worry about spelling errors before doing a string comparison
    • After each answer is given, use a Toast to tell the user if they are right or wrong, and go on to the next question
    • After the last question is answered, automatically start the ScoreActivity. Pass the total number of questions and the number of correct answers as extras in the Intent
  • ScoreActivity
    • Report the user's score and, based on their percentage correct, write an appropriate evaluation message (e.g., "Wow, 100%! You are smart!" or "Hmmm...you need to study more")
    • Have a button to take the user back to the StartActivity

You will need an external file to store at least 20 questions and 2-4 possible answers per question. This should be read by your program and turned into a data structure that QuestionActivity can easily use. The 5 or 10 questions that you present to the user for a given quiz should be randomly chosen from the overall pool.

You can make up these questions yourself or find them online. Here's a set I found that you can grab to save time.

For simplicity, don't use images or other multimedia resources in your questions and/or answers.

Submission

Submit your entire project directory (code + resources) to Sakai. Please zip or tar it before submission.