Create a constructor in this class and inside constructor

Assignment Help JAVA Programming
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

Reference no: EM133289728

Questions Cloud

What specifically interests you about these possible careers : What specifically interests you about these possible careers? What is your personal definition of living the "good" life? Is it monetary, happiness, etc.?
How would you explain the boards selection of standard : Discuss the types, sources, and relative amount of power for the three main characters in this story and How might Lassiter have increased her power
About Fair Trade : The book talked about coffee being the most important fair-trade commodity, what is your feeling about fair-trade coffee?
Discuss few areas for application of quantitative analysis : Discuss few areas for application of quantitative analysis in your organization or organization you are familiar with for decision making
Create a constructor in this class and inside constructor : Create a constructor in this class and inside the constructor, initialise the variable you declared, using your name as the value
What kind of family crises may your family : What kind of family crises may your family have experienced in the ten years that will have elapsed between now and 2032?
Service constraints and capacity of service delivery : Referrals may be necessary when the service constraints and capacity of service delivery does not meet the needs of the client as they exceed the limitations
Procedures to reconcile total wages for pay period : Explain how and the procedures to reconcile total wages for pay period, check and correct irregularities and refer to designated persons for resolution
Definition of situation is real in its consequences : The Thomas Theorem proposes that "the definition of a situation is real in its consequences." What does this mean or imply ontologically?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write program that prompts user to enter an input file name

Write a Java program called Tram.java that, firstly, prompts the user to enter an input file name. To practise reading from and writing to the console.

  Write a client-server message board application

Write a client-server message board application that supports encryption and authentication of messages and The server keeps all the posts, in the order

  Anbsp build a student record managing system application by

a.nbsp build a student record managing system application by doing the following1.nbsp create a student inheritance

  Functioning java application.

Your final project must be a complete and functioning Java application.

  Java program to create a tree

Java program to create a tree, generate class - BottomUpTwoThreeFourTree, BottomUpTwoThreeFourTree,

  Draw a uml diagram for the classes

Draw a UML diagram for the classes. Implement the classes, and write a test program that creates a salaried employee and two hourly employees.

  Implement the getperimeter that returns the perimeter

Design a class named Triangle that extends GeometricObject. The class contains three double data fields named side1, side2, and side3 with default values 1.0 to denote three sides of the triangle. Implement the getPerimeter that returns the perim..

  Create a java program the displays the state bird and flower

Write a Java program the displays the State bird and flower. The program should prompt the user to enter a State and print both the State bird and flower.

  Sources of law articles 34 and 36 tfeu

Critically discuss the 'market access' test developed by the CJEU, making reference to the freedom of movement of goods case law.

  Writing a program for the kerbal space committee

You are writing a program for the Kerbal Space Committee. Write a test plan enough test cases to convince yourself that the code works

  Write a program to create a file named "numbers.dat".

Write a program to create a file named "numbers.dat". Then create an algorithm that adds all even numbered integers from 1 to 100, separated by a comma.

  Maintaining an ethical law enforcement agency

What role does police hiring and training play in maintaining an ethical law enforcement agency? What are key issues facing law enforcement leaders when hiring

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd