Write a PHP script to implement a function which will display the current date.

Write a PHP script to implement a function which will display the current date. Also, have the script print out a message stating how many days until your birthday. You can “hardcode” your birth date into the script and have the script calculate the number of days until your birthday any way that you wish.

Programming Fundamentals (48023) – Assignment 2

Due date: Monday, 4th June 2012, 9:00 am.

Value: 20%

Topics: Control flow, Arrays.

Objectives: This assignment supports objectives 1-5.


Assignment 2 extends the game of Assignment 1 to support any number of enemies, which are

to be stored as an array.

Skeleton code

Download the skeleton code from UTSOnline/Assignments/Assignment 2/Skeleton Code. Your

solution must be based on this skeleton code.

Minimum requirements

To receive any marks, your solution must meet the following minimum requirements:

1. IMPORTANT: In your project, you will find a white document icon with a folded

corner. This is the README file for your project.

In this README file, you must keep a journal of every change that you submit to

plate. Each journal entry should begin on a new line, starting with the date of the

journal entry. In each journal entry, you should give an explanation of the code you

changed. For example:


14th of May – My first attempt at Task 2w. I added a method inside EnemyShip

to update the xyz field, and then I modified foo() to loop over all of the

enemy ships and call that method.

15th of May – Fixed the ArrayIndexOutOfBoundsException in method foo() by

making sure the for loop goes only up to position array.length-1.

15th of May – Fixed a few small indentation mistakes.

You should always submit your progress to PLATE in small increments, and include a

journal entry along with each small increment that you make. For example, after

making your first attempt at task 1a below, add your journal entry immediately to the

README file and then submit your project to PLATE.

If you do not update your journal in this manner for any part of the assignment, then

you will not receive marks for that part of the assignment.

Programming Fundamentals (48023) Autumn 2012 Assignment 2

Page 1

You must regularly submit to PLATE while developing your solution. You should

definitely NOT suddenly submit a completely working solution close to or on the due

date without submitting your progress (journal), because there will be no evidence that

you developed your solution. Any student who submits a substantial solution without

an equally substantial record of previous submissions (journal) during development will

receive ZERO.

2. Your solution must be based on the given skeleton code.

3. Your solution output must exactly match the benchmark output that is shown when

submitting to PLATE.

4. Any existing public methods, fields or classes in the skeleton code must not be

renamed, have their parameters added/removed or return types changed, although you

are free to add additional methods, fields and classes.

5. Tasks will not be marked unless they are completed in the order specified below.

6. To receive marks for the HD Task, you must be present to demonstrate your solution in

your final lab (week 14).

Specification and Tasks

Before beginning, download and open the skeleton code from UTSOnline. This project

contains a solution to Assignment 1 which must be used as a starting point for Assignment2.

The skeleton code project may be started by right-clicking on the UI class and selecting the

main() method.

An alternative graphical user interface has also been provided for students who are curious to

see how graphics could be added to the program. To run this, right-click on the GUI class and

select its main() method. You are not required to make modifications to this class, and you are

free to remove it from your project at any time.

Task 1: Rewrite the program to use arrays (40 marks)

It is important to complete the following tasks exactly as specified, and exactly in the same

order. If you do not, PLATE will not be able to mark you. Be sure to submit your progress to

PLATE regularly.

 1a) Replace the enemy1, enemy2 and enemy3 fields by a single array called enemies.

Throughout your Game, each time you refer to one of the fields enemy1, enemy2 or

enemy3, replace that reference to the field by a reference to a particular position in the

enemies array. For example, whenever you refer to enemy1, you should refer to

enemies[0] instead. In order to avoid a NullPointerException, you must also create the

enemies array in the constructor before you attempt to store enemies into it.

 1b) Notice that the Game constructor now reads the number of enemies from the user

and stores this into a local variable numEnemies. Modify your constructor so that it no

Programming Fundamentals (48023) Autumn 2012 Assignment 2

Page 2

longer creates 3 enemies, but instead creates however enemies the user requested,

according to the number that is stored in the local variable numEnemies.

Modify each of the following methods to take into account the true length of the enemies array,

rather than assuming 3 enemies:

 1c) toString()

 1d) print()

 1e) moveEnemies()

 1f) movePlayer()

 1g) over()

Task 2: Add new features (50 marks)

The following tasks are of varying levels of difficulty. In some cases, you may decide to skip a

task and move on to the next one, unless that task is marked as REQUIRED. Any task marked

as required cannot be skipped, and PLATE will not continue marking the later tasks until that

task is correctly implemented. Be sure to submit your progress to PLATE regularly.

 2a) If the user types ‘1’ after the “move:” prompt, this will cause all of the enemy ships

to reverse direction.

 2b) If a gun fires when multiple enemies are lined up in front of the gun, only the

enemy closest to the gun will be hit. Hint: The modify the fire() method in PlayerShip

and Gun to take the entire array of enemies, rather than a single enemy.

 2c) If the user types ‘2’ after the “move:” prompt, all of the enemies in the array will be

sorted so that the enemy with the smallest x position will be placed into enemies[0], the

next smallest will be placed into enemies[1], and so on. You must implement one of the

sorting algorithms presented in the lectures.

 2d) (REQUIRED) If an enemy is destroyed, it is resurrected 3*numEnemies moves

later with its initial life intact.

 2e) If a user inputs a velocity for an enemy greater than 1, or less than -1, the velocity

will indicate how many positions the enemy will move in one step. Care is required

when an enemy hits a boundary and turns in the opposite direction. For example, if an

enemy is at position 2 and it moves at velocity 4, it will end up at position 6. But if the

enemy is at position 3 and it moves at velocity 4, it will end up at position 5, because it

would have hit the boundary and turned around before being able to move a total

distance of 4 positions. After it has turned around, it’s velocity would change to -4 to

indicate that it was moving left. For further clarification, submit your project to PLATE

to see the expected output.

 2e) If the user types ‘3’ after the “move:” prompt, whichever enemy is directly in front

of the player will be moved back to the farthest row of enemies, and every enemy that

was behind it will be moved forward one row. For example, if there are 5 enemies

e1,e2,e3,e4,e5 and enemy e3 is directly in front of the player when ‘2’ is pressed, the

result will be e1,e2,e4,e5,e3.

Programming Fundamentals (48023) Autumn 2012 Assignment 2

Page 3

 2e) If the user types ‘4’, all dead enemies (i.e. marked with an ‘X’ symbol) are removed

from the array completely. Note that since it is not possible to change the length of an

existing array, you will have to create a new shorter array, and copy all of the remaining

“living” enemies from the old array into the new array.

Task 3: High Distinction (HD) task (10 marks)

This task is intended for HD students. If you complete this task, you must demonstrate it at the

week 14 lab session, and it will be marked manually by your tutor.

Make a copy of your project for Task 3. Your solution to Task 3 will be submitted separately

from your earlier tasks, and a separate submission page has been set up on PLATE for this

purpose under the name “Assignment 2 (HD Task)”. Although this task will not be

automatically marked by PLATE, you must still submit your solution to PLATE by the due

date for it to be marked.

In your new Task 3 project, modify the game so that each enemy has both an x and y position.

Now, the height of each enemy is not determined by its position in the array but rather by the

value of the y coordinate of that enemy. At the beginning of the game, the enemies should be

placed into different rows (at different y positions), and the enemy on the bottom row should be

at least 5 spaces above the player. You have some degree of freedom as to the exact positions of

your enemies, as this task will be marked manually rather than by PLATE.

Enemies not only move left and right, but also move down one step whenever they hit a left or

right boundary. If an enemy makes it to the bottom row where the player is, the player dies and

a “You Lose” message is displayed.

Marking scheme

Your solution will be marked according to the following scheme:

Task 1: Rewrite program to use arrays (40%)

Task 2: Add new features


Task 3: HD task


Indentation consistency

1 mark will be subtracted from your task 1 and

task 2 marks for each indentation mistake found.

To indent properly, code should be shifted right

by one tab between { and } and within nested

control structures such as if statements, switch

statements and loop statements. In a switch

statement, the code within each case should also

be indented.

Tasks 1, 2 and indentation consistency are marked by PLATE. However, if your journal does

not show your progress for any sub-task marked by PLATE (e.g. 1a, 1b, 1c, …) you will not

receive any marks for that sub-task. Hence, the mark awarded by PLATE is not the final mark.

Programming Fundamentals (48023) Autumn 2012 Assignment 2

Page 4

Task 3 will be marked by a tutor at the week 14 lab session while you demonstrate your

program. It will be marked based on the quality of your code, and on the quality of the program

from the user’s perspective. Your program should be easy to use and should gracefully handle

bad inputs by the user. You must also keep a journal for this task, and you must be prepared to

explain your code in person at the demonstration.

Assignment submission, demonstration and return

Your assignment must be submitted to PLATE (http://plate.it.uts.edu.au/) after completing each

task, and before the due date.

There are two parts to your submission:

1. Your assignment is to be submitted as a JAR file through the PLATE system, online, at

http://plate.it.uts.edu.au/. Tasks 1and 2 should be submitted under the assessment

“Assignment 2”, while Task 3 should be submitted under the assessment “Assignment 2

HD”. You may submit and resubmit as many times as you wish, before the due date.

Please note every time you submit your tasks on plate, the marks you receive are

indicative only. Your final marks for Assignment 2 will be available through PLATE

within 2 weeks after the due date.

2. If you attempted the HD task (Task 3), you must demonstrate your program in

your final lab session in week 14. Failure to demonstrate your HD task will result

in a zero mark for the HD task irrespective of the assignment being submitted to


If for some reason you are unable to attend on this day, you must arrange with the

subject coordinator via email, before the due date, an alternate demonstration time. You

must bring your student ID card to the demonstration as proof of your identity.

Late submission

The assignment is due at 9:00 am on Monday, 4th June 2012. Each 24 hour period after this

time is considered to be an extra day late. For example, a submission at 9:01 am on Monday,

4th June is considered 1 day late, while a submission at 9:01 am on Tuesday, 5th June is

considered 2 days late.

Your assignment will lose 20% of its original mark per day late, unless permission has been

given by the subject co-ordinator before the due date.

If your performance in an assessment item or items has been affected by extenuating or special

circumstances beyond your control you may apply for Special Consideration. Information on

how to apply can be found at http://www.sau.uts.edu.au/assessment/consideration.html

Individual assessment

This assignment must be done by yourself and not with anyone else. Group work is not

allowed and will be considered as academic misconduct.

Programming Fundamentals (48023) Autumn 2012 Assignment 2

Page 5

Academic misconduct

Working with another person on this assignment is not allowed and is considered as academic

misconduct. Do not show other people your code, or look at other people’s code, or discuss

assignment code with other people; it is an offence to have a copy of someone else’s

assignment (before the submission date). Do not post your assignment on the web. Posting

your assignment on the web and getting help through blogs or other websites is considered to

be an academic misconduct.

To detect plagiarism, the subject uses an online system called PLATE available at


Students may find it useful to consult The UTS Coursework Assessment Policy & Procedure

Manual, at http://www.gsu.uts.edu.au/policies/assessment-coursework.html

Expected work load

It is expected that this assignment will take about 12 to 18 hours of work. A well-designed

solution to task 1 and 2 is expected to use approximately 110 lines of code. Depending on your

design, Task 3 may use anywhere from 50 to 150 lines of code. Some people may complete the

task in 3 hours, and some may need 30 hours or more; there is a huge variation in students’

experience and abilities.

Frequently asked questions

A FAQ (Frequently Asked Questions) will be maintained at

UTSOnline/Assignments/Assignment 2/FAQ. FAQs and their answers will be posted there as

they arrive. You should read the FAQ at least once before you hand in your solution, but to be

safe check it every couple of days. Anything posted on the FAQ will be considered as part of

the assignment specification. The FAQ will be frozen (no new entries) two days before the due


Discussion board

A discussion board has been set up on UTSOnline to discuss the assignment. You may discuss

any task of the assignment; however you must not share actual code from the assignment on

the board. The FAQ should always be checked before asking questions on the discussion board.

Rules for use of the discussion board are published on the discussion board itself. Please read

these rules carefully.

Programming Fundamentals (48023) Autumn 2012 Assignment 2

Page 6

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.

Click Here to Make an Order Click Here to Hire a Writer