Reference no: EM132409946
CSC71001 - Programming - Southern Cross University
Assessment - Portfolio
Activity 1.8
This is the first activity in your portfolio for Assignment 3. This portfolio is worth 30% of your marks for this unit. Some activities will produce programs, others will be part of a portfolio document, and some activities will require you to complete a quiz or questions and place the answers in your portfolio.
You can create your portfolio files manually:
• Create a folder on your computer called "CSC71001_Portfolio_ rmason10". Replace rmason10 with your username for MySCU.
• In that folder, create a new Word Document called Portfolio_rmason10.docx (replace rmason10 with your username). Create a title page for your portfolio. You can be as creative as you like with this page, but it must include your name, your student number and the words "Programming Portfolio" in it.
• You will need to add headings to indicate which activities your answers are from. The first one of these (this activity!) should start on a new page and have a heading "Activity 1.8".
OR
• You can use the provided template of folders and the portfolio document. In the Assessment
3 folder, you will find the file CSC71001_Portfolio_ yourStudentUsername.zip.
• Unzip the Portfolio structure and rename folders and names to your own.
Add your name to the header in your portfolio (see Word help if you don't know how to do this) and a page number in the footer if there isn't one there already.
Some of the activities within this portfolio are going to require screenshots of your screen. If you are using Windows 7 onwards, you can use "Snipping Tool" to do this. If you are using another operating system, please do a search to work out how to take screenshots of a portion of your screen for pasting into your new document.
The activity:
1. Open the leaves-and-wombats scenario in Greenfoot, if not already open.
2. Create leaf and wombat objects in various places around your world.
3. Create 2 wombats and at least 10 leaves.
4. Take a screenshot of the world and paste into your portfolio.
5. That's it! Save your document
Activity 2-11 Portfolio Activity
This is the second activity in your portfolio for Assignment 3. This portfolio is worth 30% of your marks for this unit. As I said in the first Module, some activities will produce programs, others will be part of a portfolio document, and some activities will require you to complete a quiz or questions and place the answers in your portfolio.
Complete the following activity and then save your activity in your portfolio folder. It will automatically be named fatcat.
The activity:
1. Continue with the fatcat activity from last activity.
2. Write your name and student id in the comments after @author. Add a date and version number after @version.
3. Make the cat do a routine of your choice, consisting of a number of the available actions in sequence, as well as some conditional actions (actions it will only do if a particular condition is satisfied). Make sure there are at least 8 activities (you can repeat some).
4. Make sure you aren't doing the same activities as your friends. We would expect that every 'fat cat' will be different. Remember you must be able to explain your code if we ask.
5. Save your fatcat scenario into your portfolio folder. You can do this from your scenario by using Scenario > Save As. Under the Module 2 folder in your portfolio, create a folder (e.g. MyFatCat) and save your scenario there.
Activity 3-16 Crabworld Application
Complete the Crabworld activities to this point in the study guide. In Greenfoot, export your resulting program, as a JAR application. Save in your portfolio folder.
Activity 3-17 Crabworld Archive
In Greenfoot, export the program in Activity 3-16 as a Greenfoot Archive. Save in your portfolio folder.
Activity R3-6
1. Ensure you have completed the previous fatcat activities before going further.
2. Change your code so that if the cat ends up at the edge, the program stops.
3. Export your project as a stand-alone (JAR) application.
4. Save your project as a Greenfoot archive, in your portfolio folder. This will become part of your portfolio.
Activity R4-3 PORTFOLIO ACTIVITY
Note: you will need a microphone for this activity. If you do not have a microphone, please complete the alternative activity (Activity R4.4).
Only the scenario part of this activity is to be submitted as part of your portfolio. The first questions will help you to find the correct answers and code for the scenario. The parts marked with a *** are to be completed as part of your portfolio.
1. Open the stickman scenario provided ***
2. The Greenfoot class has a method to get the noise level from the computer's microphone. Find this method in the API documentation. How many parameters does it have?
3. What is the return type of this method? What does this tell us?
4. What are the possible values returned from this method?
5. Is this method static or not? What does that tell us?
6. How do we call this method? Write down a correct method call to this method:
7. In your stickman scenario, make the stickman move to the RIGHT, so that when you run your scenario, he walks over to the right side of the screen. Note: no keyboard input is required.
8. Using an if-statement and the microphone input method you found above, make the stickman move RIGHT only when you make some noise. Experiment with different values for the noise level. This will depend on your microphone and your environment. A good starting point is to make him move when the microphone level is greater than 3. Test.
9. Make the stickman move LEFT when you make some noise but move continuously RIGHT if there is no noise. Test. Try to keep him near the centre of the screen by shouting.
10. Move the code that moves left when you make noise into its own method. Call this method moveLeftIfNoise. Test. Make sure it works as before
11. Add another method to your class called gameOver. This method should be called if the stickman reaches the edge of the screen. When called, the method plays a game-over sound and stops the scenario.
12. Move the check for the game-over condition itself into a separate method called checkGameOver. The act method should call checkGameOver which in turn calls gameOver if appropriate.
13. Save your game as a JAR application
14. Save your game as a Greenfoot Archive file
15. Save both of these into your Portfolio folder.
Activity R4-4 PORTFOLIO ACTIVITY
Note: Only complete this activity IF you have no microphone for the previous activity. You
do not have to complete both activities for your portfolio.
Only the scenario part of this activity is to be submitted as part of your portfolio. The first questions
will help you to find the correct answers and code for the scenario. The parts marked with a *** are
to be completed as part of your portfolio.
1. Open the stickman scenario provided ***
2. We have previously used the move(distance) method in our actors to move to the right or left. How would we move a random distance between 0 and 10 units?
a. to the left?
b. to the right?
3. In your stickman scenario, make the stickman move to the RIGHT, so that when you run your scenario, he walks over to the right side of the screen. Note: no keyboard input is required.
4. Using an if-statement and the keyboard handling you learned in this module, make the stickman move RIGHT only when you press the space bar. Test.
5. Change your code to make the stickman move LEFT a random amount between 0 and 10 when the space bar is pressed, but move continuously RIGHT (again, random distances) if it is not pressed. Test. Try to keep him near the centre of the screen.
6. Move the code that moves left when you press the key into its own method. Call this CSC71001 - Module 4 - Page 17 method moveIfSpace. Test. Make sure it works as before
7. Add another method to your class called gameOver. This method should be called if the stickman reaches the edge of the screen. When called, the method plays a game-over sound and stops the scenario.
8. Move the check for the game-over condition itself into a separate method called checkGameOver. The act method should call checkGameOver which in turn calls gameOver if appropriate.
9. Save your game as a JAR application
10. Save your game as a Greenfoot Archive file
11. Save both of these into your Portfolio folder.
Activity 5-10 Portfolio Activity
1. Complete the work up until this point to animate the crab.
CSC71001 Module 5 - Page 14
2. Use the act button to test, then use Run.
3. Refactor your code to make it more maintainable. Test again.
4. Save your work as a Greenfoot archive in your portfolio folder.
Activity R5-4 Portfolio Activity
1. Complete the game to this point (see previous exercises).
2. Investigate the showText method of the World class. How many parameters does it have?
What are they? What does it return? What does it do? Write down your answers in your word document under a heading called "Activity R5-4".
3. Display the game timer on screen using the showText method. You can do this in the CrabWorld's act method.
4. Save your scenario as " R5-4_rmason10.gfar ". Replace rmason10 with your username for MySCU.
Activity R5-5 Portfolio Activity
1. Under a heading "My game theme" in your portfolio document, explain the idea of the theme of behind your practical skills game. This theme will be used for your assignment 2, Practical skills, and you will continue to use this theme throughout the remainder of the semester for your portfolio assessment.
Activity 6-3 The WhiteCell class Portfolio Activity
With the scenario open, open the WhiteCell class in the code editor.
You will see that the act() method calls another method (over and over) called "checkKeyPress".
It's this method that we will look at in more detail.
This method uses the Greenfoot.isKeyDown() method we have used previously to turn the crab left and right. In this method, it captures when the user presses the "up" or "down" arrows.
if (Greenfoot.isKeyDown("up"))
{
// move the cell up
}
if (Greenfoot.isKeyDown("down"))
{
// move the cell down
}
Now to look at how it actually moves the cell up and down. The code uses three methods that we
haven't used before, from the Actor class: setLocation, getX and getY.
These methods are well named so we could probably guess what they do, but let's look it up.
1. Write down the signature for the three methods:
2. Write down an example of a call to the setLocation method:
Save these answers in your Portfolio under a heading "Activity 6-3".
To understand the rest of the code in this method, we need to do a small side-track.
Activity 6-19 Simple scoring for your game (Portfolio activity)
1. Modify your little-crab games' code from last week so that when the player collects a food piece you add 10 points to the score.
2. Modify your little-crab games' code from last week so that instead of the game ending when the player is hit by the enemy or the timer runs out (you can comment out this code), that the enemy is removed, and 30 points is taken away from the score.
3. Save your game as A6-19_rmason10.gfar. Replace rmason10 with your username for MySCU
Activity R7-1 Portfolio Activity
The following activities are to be recorded in you're the Portfolio word document under the heading Activity R7-1.
1. Declare and initialise a String array called food with the names of three different types of food that you may use in your game. You may wish to use the food you already use and/or create new food names.
2. Using a while loop, write the code that will play one of your games' sound files 7 times.
3. Consider the following code:
int x = 25;
int i = 1;
while (i < 5)
{
x = x - 5;
i += 1;
}
What is the value of x after this code has executed?
What is the value of i after this code has executed?
Activity R7-7 Portfolio Activity
This activity will update your existing game you created for the Practical skills assessment. Each Implementation, when it is completed, should be saved as a gfar in your portfolio folder. For the next few activities you will be using code to add new Actor objects to your scene. Remove all the code within the prepare method so that no objects are added to the scene. You will be starting with an empty prepare method. If you called your prepare method something different just remove all the code from that method.
Save your program in the Portfolio folder as ActivityR7-7_rmason10.gfar. Replace rmason10 with
your username for MySCU.
Activity R7-8 Portfolio Activity
This activity will update your existing game you created for the Practical skills assessment. Each Implementation, when it is completed, should be saved as a gfar in your portfolio folder.
In your games' world class that you created (not the actual World class):
1. In the prepare method, write a line of code to create a new Player object ready to be added to the world.
2. Also, in the prepare method, add code to add the new player object to the middle of the world.
Save your program in the Portfolio folder as ActivityR7-8_rmason10.gfar. Replace rmason10 with your username for MySCU.
Activity R7-9 Portfolio Activity
This activity will update your existing game you created for the Practical skills assessment.
Each Implementation, when it is completed, should be saved as a gfar in your portfolio folder.
1. At the top of your world class, add code to hold an array of 3 Enemy objects in the world (do not add code to add the enemy objects to the world just yet as this will be done in the next activity)
2. If you do not have a score for your game add code to record and display a score. You can implement the score for your game by referring to Activities 6-15 through to 6-19 from last week. The final "Bonus" activity in Module 11 will assume you have implemented code similar to this. The "Bonus" activity will display a game over screen.
3. Extra: Create another class called scorePanel. This will represent a scoring panel that sits behind your actual game score. You may choose an appropriate image to use. Depending on your Image you may need to scale It larger or smaller. You can experiment by using getImage(), scale(x,y); where x and y are integer values;
Save your program in the Portfolio folder as ActivityR7-9_rmason10.gfar. Replace rmason10 with your username for MySCU.
Activity R7-10 Portfolio Activity
This activity will update your existing game you created for the Practical skills assessment. Each
Implementation, when it is completed, should be saved as a gfar in your portfolio folder.
In the method you will use to setup the world, use a ' while loop' to:
1. Add the array of Enemy objects to the world in random locations
2. Add code to create and add a random number of between 5 and 10 Food objects to the world in random locations.
Make sure to test your game by resetting it and checking to make sure that all the objects, other than the Player class, appear at random locations in the world.
Activity R8-1 Portfolio Activity
This activity will update your existing game you created for the Practical skills assessment. Each
Implementation, when it is completed, should be saved as a gfar in your portfolio folder.
In your games' world class that you created (not the actual World class) create a constant variable
called "enemy array" and set its value to 3. Make sure to use the correct naming conventions.
Replace the while loops in your game to for loops to add the array of enemy objects to the world in
random locations. In this code you will implement the constant variable you declared earlier.
Make sure to test your game.
Save your program in the Portfolio as ActivityR8-1_rmason10.gfar. Replace rmason10 with your
username for MySCU.
Activity R8-2 Portfolio Activity
This activity will update your existing game you created for the Practical skills assessment. Each
Implementation, when it is completed, should be saved as a gfar in your portfolio folder.
In your food class or if you have more than 1, choose only 1:
1. Declare and initialise a GreenfootImage instance variable that will hold a new Food image.
This image should have the same theme as your Food class (Look at the video on using
other images and see the ***Note at the end of this activity)
2. Create a default constructor that takes no parameters and does not initialise any fields eg:
public Food(){ //no code goes in here }
3. Create a second constructor that takes 1 integer parameter. This constructor will set the
image of the food to either the default image you use or the new food image. 1 will mean the
default image is called and 2 will mean that the new image is called.
In your World class, within your prepare method (you may wish to comment out previous loops);
4. Using at least one loop, create a squadron of food objects in the shape of one of your initials
that uses the second constructor. The argument you will pass to the second constructor's
parameter will be a random number of either 1 or 2. For example, instead of using new
Food() I might use new Food(1) or new Food(2) for testing purposes (this is not random, you
will have to add random functionality to your code).
5. In addition to the above activity, using two nested for loops (a loop within another loop),
create a border around your scene of your initial. You will use one nested for loop to create
the top and the bottom border and the other nested for loop to create the left and right border.
Optional extras:
***Note: Getting images:
A good place to get sprites to use for your Greenfoot projects is Google images - using the search "sprites png" or "sprite sheet png". Of course, you need to be careful that you have permission to use the images, but these are great to use. You can use the free online image editor to crop them to size.
Activity R9-6 PORTFOLIO ACTIVITY
This activity will update your existing game you created for the Practical skills assessment.
Each Implementation, when it is completed, should be saved as a gfar in your portfolio folder.
Using your own scenario, implement code that demonstrates a for-each loop. Some ideas for using a for-each loop might include one of the following:
Once a certain score is reached:
• adjust the speed of each enemy or food object
• reset the position of each object to random locations on the screen
• make each enemy turn towards the player
• change the image of each enemy or food
While the game is running:
• swap images like a star twinkling or some other form of animation
• make all enemy or food objects randomly turn in the same direction
On keypress
• change the state (spin, move, or turn) of each enemy or food object.
• change the image of each enemy or food object
These are just a few ideas. Feel free to implement your own idea. If you are unsure, please ask your tutor.
Activity R9-7 PORTFOLIO ACTIVITY
In your portfolio document, under the heading "Module 9-7: For-Each Loop", write a brief description of your game and explain clearly how your game demonstrates a for-each loop. Do not post code into this section. You must also explain where in your code you implemented the
for-each loop.
Activity R10-4 PORTFOLIO ACTIVITY
This activity will update your existing game you created for the Practical skills assessment. Each implementation, when it is completed, should be saved as a gfar in your portfolio folder.
1. In your Food class; If you do not have a variable to store speed at this stage you should implement one now. Modify your Food class code so that an instance variable stores the speed a Food object.
2. In your Food class; If you do not have a variable to store points at this stage, you should implement one now. Modify your Food class code so that an instance variable stores the points that this Food object is worth.
3. If you do not have one already. add a getPoints() method to your Food class that gets the points that this Food object is worth.
4. If you do not have one already. add a getSpeed() method to your Food class that gets the speed value of a Food object.
5. Modify your Player code so it adds the Food object's points to the score each time, by using this new getPoints() method of the Food. (note: you may have implemented this already) Save your program in the Portfolio as ActivityR10-4_rmason10.gfar. Replace rmason10 with your username for MySCU.
Activity R10-5 PORTFOLIO ACTIVITY
This activity will update your existing game you created for the Practical skills assessment. Each implementation, when it is completed, should be saved as a gfar in your portfolio folder.
You should already have 2 constructors in your Food class. One constructor that takes no parameters and another constructor that takes an Integer as a parameter. If you do not have these constructors, you should refer to the Module 8 Portfolio activities.
We will now create a third constructor. This constructor will take one String parameter. The three string values we will pass to this constructor are "good", "bad" and "normal".
1. Write code in your Food class to create this constructor.
2. Inside the third constructor write an if statement to check to see what value has been passed to the constructor. The IF statement should check if the value is "good", "bad" or "normal".
If the String is "good", this constructor should set the speed to 5, set the image to an appropriate food Image, and set the points to 50. If the String is "bad" this constructor should set the speed to 2, set the image to a bad food Image, and set the points to -100. If the String is "normal" this constructor should set the speed to 3 and set the points to 25. Save your program in the Portfolio as ActivityR10-5_rmason10.gfar. Replace rmason10 with your username for MySCU.
Activity R10-6 PORTFOLIO ACTIVITY
This activity will update your existing game you created for the Practical skills assessment. Each implementation, when it is completed, should be saved as a gfar in your portfolio folder. Add code to the act method of your World class to keep adding objects to the world. You can choose how often you would like the objects to be added to the World. The code will need to implement the third constructor. You will need to implement an IF statement to determine which Food object will be added to the world at random.
Activity R10-7 PORTFOLIO ACTIVITY
In your portfolio document, under the heading "Module 10: Overloading Constructors", write a description of your scenario and explain how this demonstrates overloading constructor methods for your scenario.
Specifications
Your task is to complete a number of activities included in the study guide, and identified as "Portfolio Activity"s. These activities range from recording a screenshot of your work, to exporting archives of your game, to submitting a guided activity from the study guide, to providing an example to illustrate a particular concept, including an explanation in your own words.
The deliverables of this assignment are:
1. A portfolio document (.doc or .docx) with title page, contents, page numbers and headings. Included in this document are various answers to activities as well as explanations and screenshots.
2. A folder (zipped for submission) with all gfar (Greenfoot archive) files which are answers for the activities indicated throughout the study guide. These should be named as specified through the study guide.
It is important to note that some of the activities in the Portfolio will extend on your Practical skills game. This means that the theme of your game from Assessment 2 must remain the same throughout the Portfolio. You may enhance your images and sounds as you wish.
Attachment:- Programming.rar
Attachment:- Portfolio.zip