• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

please help me

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assignment 2
Due date:Friday, 29 April 2005
Value:15% of final mark
Rationale
This assignment has been designed to give students the opportunity to demonstrate their skill in:

�using a user defined class
�passing arguments to methods of a user defined class
�writing methods which enable objects of a user defined class to show appropriate behaviours
�designing an application requiring user interaction.
�using good programming style. To better understand this, you should study the worked examples provided in the notes and text book.
�at HD level, extending the program using methods of their own devising.
�your program must not crash for any legal user action. That is, it must be robust!

It is important to understand that as part of the assessment process, the marker will compile and run your submitted programs and view output on screen however, it is not enough to merely recreate the results on screen. To get full marks your program must be free of poor programming style and you must use the file given below.
Question 1 � Mobile Phone Plan
Problem Statement (30 marks)

In a particular mobile plan, local calls between 700hrs and 1900hrs are charged at $0.60 per minute. Long distance calls (to places over 100 km away) during these hours are charged at $1.10 per minute. At other times calls are charged at half the normal rate.

A program is required which calculates the total cost of an arbitrary number of calls. For each call, the user enters a time value (in 24hr mode), a distance (in kilometres), and a call length (in minutes). The program then displays the cost of that call and also adds the cost onto a cumulative total.

When the user has no more calls to process, they enter a time value of -999 instead of a legal time. When the program reads this sentinel value it displays the total cost of all the processed calls and ends

Design
Your solution program should be implemented in a single Java source code file which contains a main method and one other separate static method.

The separate method should encapsulate the actual calculation of each call cost. It should accept three arguments: a time value (int), a distance (int) and a call length (double). It should calculate the cost of the �phone call� using these arguments and return it.

The main method should contain the overall logic of the solution. It should prompt the user for each piece of data, read the data from the keyboard and then invoke the method described above to do the calculations. When the cost is returned, its value should be captured into a variable, displayed on the screen and accumulated into the grand total.

It is recommended that you use a �sentinel-controlled, while loop� in Main to manage the processing of phone calls. Make sure that when the -999 is read, it is not processed as a time value.

The snippet below shows what a typical program might look like to a user�

Enter a time in 24hr mode (use -999 to quite): 800
Enter a distance in kilometres: 70
Enter the length of the call in minutes: 1.5
That call will cost 0.9 dollars

Enter a time in 24hr mode(use -999 to quite): 2100
Enter a distance in kilometres: 275
Enter the length of the call in minutes: 6
That call will cost 3.3 dollars

Enter a time in 24hr mode (use -999 to quite): -999
The total cost of these calls is 4.2 dollars

Question 2 � Tank Battle
Problem statement

You are to construct a game where tanks battle to the death. The tanks have an X coordinate, a Y coordinate, a value for armour and a value for firepower. The tanks will move randomly around the grid. There are special squares where they may upgrade their armour or their firepower. When they land on the same grid coordinate they will fire on each other, so each tank will have its armour value decreased by the others fire power. When one tank has negative armour, the other tank is the victor and the game ends.

This game requires three class classes as well as a Client which provides the user interface. The first class is Direction, a method of which will return: up, down, left or right. The second is the Die class given on the concordance web page at:

Http://www.csu.edu.au/faculty/sciagr/sit/subjects/itc129/utils/index.html

The third, which you will write is called Tank, which defines Tank a class of objects that will move around a grid which goes from (10, 10) to (-10, -10).

A tank starts at (0, 0) then gets instructions to go a number of units (from the Die class) in a certain direction (from the Direction class).
Part A � Complete this programming to achieve a Pass grade
Value (5 + 10 +10) marks

(i)Create the Direction class. It�s easiest to start with the Die.java and modify its method so that is only picks numbers from 1 to 4. Also change the roll() method so that once you have a value for laseFace, to include code so that if the number selected is 1, set your direction variable as �up� � then 2 = �down�, 3 = �left� and 4 = �right�. Make sure you have a Direction() constructor and save as Direction.java.

Create a client program (containing main) in which both a die and a direction object are instantiated. Then use a while loop to print out 50 lines of random number and direction.
Eg. 6 up
3 left ect..

(ii)Create a class called �Tank�. A tank has attributes x pos, y pos, armour and firepower. You will need to write setter and getter methods for all these attributes. The initial values are (0, 0, 10, 1).

(iii)Modify your client class so that a Tank (that starts at x=0, y=0), moves about by responding to the Die and Direction rolls. Then print out inside your loop to show:

NumberDirectionxValueyValueArmourfirepower
5Up35101
Part B � Complete this programming to achieve a Credit grade
Value (2.5 +2.5 +5 +5) marks

(i)Your tank must move in a grid which goes between -10 and 10 in both x and y coordinates. Declare a static constant called gridSize with a value of 10. Use gridSize throughout your program, as we might change the size. Keep your tank inside this grid. If the tank is at x=8 and y=0 then the next roll sends it 6 right, your tank should move 2 to the right then bounce back 4 in the opposite direction. Thus finishing at x = 6.

Hints:
If the x-value is more than 10 � then x-value = 2 X gridSize � x-value.
If the x-value is less than � 10, then x-value = -2 gridSize � x-value.

Print out BOUNCE on the right side of the screen when you apply these equations.

Again print out the 50 lines of values.

(ii)Have 2 special squares. One square at (3, 3) adds 10 to the armour value.
The square at (-3, -3) adds 1 to the firepower.
If a tank hits the armour square print out �Yipee � more armour.�
If a tank hits the fire power square print out �yippee � more fire
power.�

Continue to print out the 50 lines of values

(iii)If you have not already done so, now is the time to make sure you use methods. This is to allow the introduction of a second tank. I suggest the following for a method which responds to the Die and Direction rolls, and makes sure that tank stays in the grid. Note that we send off the die and direction roll plus the tank. We receive back the integer �bounce� which gives us information about whether a tank bounced against the grid

Bounce = determineCoords(rollDie1, rollDir1, tankOne);

Write a second method that is to allow for the special armour and fire power squares.

Specials=doSpecials(tankOne);

Specials tell us information for printing out yippee messages.
Hint: you should only be printing out from within the main.

(iv)Introduce a second tank moving around the grid. Also print out its values. When the tanks are on the same square, they fire on each other. So each tank will have its armour value decreased by the others firepower. This is the only affect. Print out �BATTLE� on a separate line.
Print out values until one tank is destroyed.

Once the battle finishes a statement should be printed which says something like:
�After 6,756 moves and 27 battles, Tank One was the victor. Hail Tank One!
Coordinates (-5, 1) will be sacred forever!�


Part C � Going for Distinction
Value 30 Marks

Use your own creativity to enhance the game.

This is your chance to show the marker what you can really do. The enhancement needs to be significant before a Distinction grade will be considered. You would need to do something pretty extraordinary to be considered for a HD.

Write a page which explains:
oyour enhancements;
ohow you accomplished the above;
oany difficulties you encountered.

Notes about marking
No marks are given for almost meeting the requirements of a particular level.
In order to obtain the marks for a given level, you must demonstrate that your program produces the correct results on screen with no errors in the code. Your mark may then vary in a range determined by the presentation of your assignment, quality of the code you have written etc.

What if your program won�t run? Submit it anyway. It is important to stay in the game. You may improve over the course of the semester and finally pass provided you don�t give up too soon.

What to submit
Please read carefully
You will need to submit the items listed below.

A. Printed Documentation

1.Evidence of Planning
a.You should submit your planning for the program, whether it is a flowchart, or pseudocode. You do not need to use a word processor to create this planning as it should be done before you start writing your program.
2.Source code
b.You should include comments in your code stating:
i.Your name and student ID as comments within the code
ii.the level at which you are attempting the assignment.
iii.Information about the program, including the date and version and purpose
iv.what each method does and
v.explaining any complex sections of code
vi.You should of course use meaningful variable names so that your code is to some extent self-documenting.
3.Sample output
c.Submit the sample output, including various types of input, valid and invalid.

B. Soft Copies of your program and source code:
1.Submit a diskette containing
a.ALL of your Java source code (your program)
b.ALL of the corresponding class files: you will create the class files through use of the Javac complier.
2.Make sure the files are not corrupted as they will need to be executed.

C. Answers to Written Questions
1.Submit a printed word document containing your answers to the written questions in Part (C)

Note about testing and plagiarism
It is very important that you complete this assignment alone. You may of course obtain general assistance from the lecturing staff in the subject and your peers, but the coding must be carried out yourself. It is normally quite easy to detect when two or more students work together on their coding.

Students who hand in substantially similar assignments or whose programs do not match their demonstration on testing will fail the assignment
 
Ranch Hand
Posts: 168
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How much work have you done so far for this assignment?
You have posted this to more than one forum. You must be so desperate. Why don't you start with what you have learned in the classroom?
[ April 18, 2005: Message edited by: Yosi Hendarsjah ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jeyasudhan chelvaraj:

Note about testing and plagiarism
It is very important that you complete this assignment alone. You may of course obtain general assistance from the lecturing staff in the subject and your peers, but the coding must be carried out yourself.



So, given that -- what general assistance do you need?
 
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've seen a few diguised assignments here before, but woah doggie! This one isn't even diguised! Podner, I'd say you need to try sumthin first, and ask if you get stuck!

--Dale--
 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe he was trying for the Longest Post award?
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly is your question? No one here will do your homework. Try breaking your assignment into smaller managable task and post again when you have specific questions.
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey tell me when this assignment is due...I will try to finish it just before that...go and play with your xbox meanwhile..trust me it will be delivered on schedule and according to specs...just like any other IT project.

**clicks add reply and forgets about this post**

ps: yes I am going to hell
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
venkataraman
i am waiting for you in hell.
i forgot about this post the day it was posted.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic