Reference no: EM133289728
REQUIRED for Assessment:
1. Continuing from the previous activity, add your name, student ID and date to the class comments of each class you have just created.
2. Declare a variable in your subclass of Actor. In this class, the variable name will be your first name and the variable type will be a String.
3. Above the variable in the same class, explain in your own words what variable declaration is.
4. Create a constructor in this class and inside the constructor, initialise the variable you declared, using your name as the value.
5. Explain in your own words, using comments inside the constructor what variable initialisation is.
6. Write comments above the constructor in the first class, explaining in your own words the purpose of a constructor.
7. EXPORT your project as a gfar. Name this file in the following format studentID-M3-PAT2.gfar. Replace studentID with your studentID. For example mine would be 23860067-M3-PAT2.gfar
Assessment 2: Module 3 Activity Task Three
1. Continuing on from the previous activity - Record your own voice, explaining in your own words, static methods, and at least two ways we can use them in Greenfoot. This should be no more than a couple of minutes.
2. Save your sound file inside the sounds folder of your project. In the world class prepare() method, write code to play this audio file.
3. EXPORT your project as a gfar. Name this file in the following format studentID-M3-PAT3.gfar. Replacing studentID with your studentID. For example, mine would be 23860067-M3-PAT3.gfar
Assessment 3: Module 4 Activity Task One
Go to your folder for your Assessment 2, the one you created for Module 3's Portfolio Tasks. (You should have named the folder something like "studentID-PROG1001-Assessment2", for example, 22015785-PROG1001-Assessment2).
Copy the Assessment 3 "portfolio" scenario that you used for Module 3. You will continue on this scenario now for your Module 4 portfolio activity tasks.
Follow the instructions below, making sure to export your project when you are requested to do so. If for some reason you have an error in your program which prevents you from exporting your project, you will need to comment out the affected code and then export. Only GFAR files will be accepted for marking.
1. You should already have a World subclass and an Actor subclass.
2. Create a second subclass of Actor and name it according to the image selected - your image will be a transport/blue car
3. Create a third subclass of Actor and name it according to the image selected - your image will be a food/lemon
4. Add your name, student ID and date to the class comments of each class you have just created.
5. Now, open the first subclass of Actor you created and add code to move using keyboard controls using turn() or setLocation(). Then refactor this code into its own method. Make sure to call this method from your act() method.
6. Add code to any of the Actor subclasses, to demonstrate how an object can be removed from the scene by another object using the 'this' keyword. Make sure this code is refactored in its own method, called from the class's act() method, and that you use comments to explain in your own words how the method demonstrates this example.
7. EXPORT your project as a gfar. Name this file in the following format studentID-M4-PAT1.gfar. Replacing studentID with your studentID. For example, mine would be 23860067-M4-PAT1.gfar
Assessment 3: Activity Task Two
1. Continuing on from the previous activity - declare a variable in each of the two new classes you have created. In the second class, the variable name will be your last name and the variable type will be a boolean. In the third class, the variable name will be your tutor's name and the type will be a String.
2. Add getter and setter methods for each variable. Make sure the variables and methods are properly encapsulated (private & public).
3. Create a constructor for each of these classes and use the Setter methods to initialise the variables in the constructors, using values you feel are appropriate.
4. Write comments above the constructor in the second class, explaining in your own words what the purpose of encapsulation is, and how you have applied it in the two classes.
5. Write comments above the constructor in the third class, explaining in your own words why refactoring is so important.
6. EXPORT your project as a gfar. Name this file in the following format studentID-M4-PAT2.gfar. Replace studentID with your studentID. For example mine would be 23860067-M4-PAT2.gfar
Activity Task Three
1. Continuing on from the previous activity - In your world's prepare() method, add code to create one (1) object from the first class.
2. In your world, create an act() method. In this act method, add code to continuously create objects of the second and third class at random times & random locations in the Scene. Make sure one of the classes has a smaller chance of spawning objects than the other class.
3. Create a new method in the world class that will take the value of any variable from your Actor classes as an argument, and display it on-screen somewhere (you choose where). You will need a parameter to do this.
4. Open your first class. Add code to check if it is intersecting an object of the second class type. If it is, call the world's new display method to display and get the intersecting object's variable value to send as an argument to the method's parameter. Remember, you will need to use the correct Getter method for that object type.
5. Add another IF condition to check for an intersecting object of the third class type, and display its variable value if so. As with before, use the correct Getter method for that object type.
6. Refactor the code from steps 4-5 into its own method. Write a comment above this new method, explaining in your own words what it does. Make sure to call it from the act() method.
7. EXPORT your project as a gfar. Name this file in the following format studentID-M4-PAT3.gfar. Replacing studentID with your studentID. For example, mine would be 23860067-M4-PAT3.gfar
Activity Task One
Go to your folder for your Assessment 2, the one you last used for Module 4's Portfolio Tasks. (You should have named the folder something like "studentID-PROG1001-Assessment2", for example, 22015785-PROG1001-Assessment2).
Copy the Assessment 2 "portfolio" scenario that you used for Module 4. You will continue on this scenario now for your Module 5 portfolio activity tasks.
1. You should have a World subclass, and three Actor subclasses. Open the World subclass.
2. Remove the code in the world's act() method that continously creates objects of the third subclass of Actor, which you created in Module 4. (Leave the code that creates the second subclass.)
3. In the world's prepare() method, form the first letter of your name ->(E), using objects of the third subclass. Use While loops to draw lines where needed -- you should not create and add individual objects manually, at least one While loop must be present.
For example: a student has a third subclass named Pizza, her first name is Amy, so she will need to create the letter A with While loops, using Pizza objects. This will look like two long diagonal lines of pizzas, and a smaller horizontal line of pizzas in-between.
4. Make sure this code is refactored in its own method, called from the World subclass's prepare() method. Write a short comment above the method to explain in your own words what its purpose is.
5. EXPORT your project as a gfar. Name this file in the following format studentID-M5-PAT1.gfar. Replacing studentID with your studentID. For example, mine would be 23860067-M5-PAT1.gfar
Activity Task Two
1. Continuing on from the first activity - Open the second Actor subclass. In the Class constructor, declare and initialise a variable to hold a random number between 1-3. Name it sensibly.
2. Based on the value of this random number variable, you will be modifying an object in the Constructor when it is created.
a. There should be a boolean variable in this second subclass named with your last name. You will program a conditional construct to test if the boolean was set to:
o true - modify the object's image,
o false - modify the object's size;
o You should program both of these
o You should know how to do both of these things from the Module 4 activities and tutorial.
For the boolean set to true:
o declare and initialise three GreenfootImage instance variables (image1, image2, image3) at the start of the class. Assign them all valid images.
o in the Constructor, set up the three IF statements so that if the random number is 1, set the object image to image1; if 2, set to image2; if 3, set to image3.
For the boolean set to false:
o declare two local int variables in the Constructor and initialise one with the object's image height and the other with the object's image width (hint look at Module 5 Revision).
o set up the three IF statements so that if the random number is 1, increase the image height and width by 40; if 2, increase the image height and width by 15; if 3, multiply the image size by 2.
3. Insert comments above these IF statements. In these comments, write down in simple pseudocode what your code is supposed to do for all three IF statements.
4. EXPORT your project as a gfar. Name this file in the following format studentID-M5-PAT2.gfar. Replace studentID with your studentID. For example mine would be 23860067-M5-PAT2.gfar
Activity Task Three
1. Continuing on from the previous activity task - For the final activity task, you need to convert the three IF statements for the second subclass, into a switch.
2. Use the pseudocode you developed for the previous task, to guide you in creating a switch and its appropriate cases for choosing the object images / sizes for the second subclass. Remember that:
If the class's boolean variable is set to true:
o if the random number is 1, set the object image to image1;
o if the random number is 2, set the object image to image2;
o if the random number is 3, set the object image to image3;
If the class's boolean variable is set to false:
o if the random number is 1, increase the image height and width by 40;
o if the random number is 2, increase the image height and width by 15;
o if the random number is 3, multiply the image height and width by 2.
3. Make sure to include break; statements and a default case with an error message.
4. Record your own voice, explaining in your own words, the difference between an IF .. ELSE construct and a SWITCH, and what some of the conditional operators are in Greenfoot. This should be no more than a couple of minutes.
5. Save your sound file inside the sounds folder of your project. In the world class prepare() method, write code to play this audio file.
6. EXPORT your project as a gfar. Name this file in the following format studentID-M5-PAT3.gfar. Replacing studentID with your studentID. For example, mine would be 23860067-M5-PAT3.gfar
Attachment:- portfolio.rar