2013年9月28日星期六

Being studied abroad java, foreigners topic , seeking guidance , has been translated

 This post last edited by the u011808925 on 2013-09-24 18:59:46
Problem Description and background
In a distant star systems, planets Pern has been human settlement . Pern every 200 years or so, the theme of distress. Theme and fall through the atmosphere from outer space . If the meteorite reaches the ground , it will destroy the plants and animals ( including humans ) . People of Pern fire-breathing dragons, human ridden. When the subject falls dragons and riders up into the air, and try to destroy theme, before reaching the ground . If the patch dragon theme is close enough , then it's flames completely destroyed theme.

dragons come in different sizes , which is based on the color of the dragon . Larger dragons have a larger wingspan , which means that they can go and fall faster than the little dragon. However, the greater dragons do not go left or right, and smaller dragons.

bigger dragon also have a stronger flame , which means they can be further away from the subject, when they tried to destroy it , than small dragon, still successful.

This is called flame distance.

When meteorites began to decline , Dragons and riders know that the topic has been started to decline , but they do not know exactly where . Therefore , the dragon begins somewhere in the sky . When the location of the dragon and rider meteorite , then they must attempt to fly themed locations.

subject location record can be used , such as two coordinates , X1, and Y1. x1 (horizontal ) coordinates from some arbitrary point on the ground distance ( positive or negative ) . Y1 ( vertical ) axis is the height above the ground .

with two coordinates , X2 and Y2, such as the location of the dragon is also recorded . 2 X ( horizontal ) coordinates are from the same arbitrary point on the ground a distance ( positive or negative ) for the thread . Y2 ( vertical ) axis is the height above the ground dragon .

flights in lawsuits theme is divided into time slots. In a time slice , thread fell 100 units , or blow to the left or to the right level of 100 units . When the dragon for menu selection , which has continued for the entire time slice .

± represent plus or minus

Long to go left or right to use this formula at the end = oldX ± ((100 / wingspan ) * 50 )
left, so that the end is less than oldX , so less of it to end more than oldX plus

Note: X can be negative

all dragons go up or down using this formula newY a = oldY ± ( wingspan * 5 )
dragon never crashed to the ground , their land , so if it is a negative newY zero
formula for the distance between two points is the distance = √ (× 2 - × 1) 2 + (Y2 - yl ) ; 2

theme may go up or down, left or right.

explained below , is the random decision.

theme of the work to the next location .

generates a random number between 0 and 16 ( exclusive )

If the random number is 0, 1 , 3 or 11
Then , the new x1 ( horizontal ) position of the theme is 100 units to the right . Y1 ( vertical direction ) position remains unchanged.

If the random number is 5, 9 or 14
Then , the new x1 ( horizontal ) position is 100 units left-hand thread . Y1 ( vertical direction ) position remains unchanged.

any other number, in addition to those above mean
Y1 ( vertical position ) theme is 100 units , down X1 ( horizontal ) position remains unchanged.

Program Requirements

you need to write a program in Java , Analog dragon and rider trying to destroy theme.

The program starts reading the values ​​from a text file . Section 6 of the text file format. You can assume that the text file is always correct , the correct format . Your program must not hard -coded input file name. That is , your program must be in the correct format and any text file .

values ​​in the text file is stored in a local variable , one for each line of the input file in , see page 6 for a complete explanation.

Then , the generated initial position of the thread .

x1 of ( horizontal ) position 0 and 4000 generated random number between ( not included )

Y1 ( vertical direction) position of the generated random number between 1000 and 2000 ( not included)

In the text file is read , and generates the initial position of a meteorite , the user is presented a menu. Then the user to enter commands until either succeeded in destroying the dragon theme , the theme reaches the ground or the user to enter the " exit " command

command must be case-insensitive. This means that the left and left commands
must have the same result.

Shown below is an example of the menu ( note that you can customize the menu , but the input of commands that must be a text , and must be able to handle more than one word commands )

menu

Left - Left - Right to go up -
- down
flame - breathing fire between - between the exit
input selection >>

can enter commands and explanations of each command

leave

If you enter this command , the new X2 ( horizontal ) position of the dragon had used a formula , the first three . Long Y2 ( vertical ) position remains unchanged . Please note that the new location will be lower than the old X2 X2 position .

Right

If you enter this command , the new X2 ( horizontal ) position of the dragon had used a formula , the first three . Long Y2 ( vertical ) position remains unchanged . Please note that the new location will be larger than the old X2 X2 position .

on

If you enter this command , then the new Y2 ( vertical ) position of the dragon
using the formula on page 3 . Long X2 ( horizontal) position remains unchanged. Note that the new position will be greater than the old Y2 Y2 locations.

next

If you enter this command , then the new Y2 ( vertical ) position of the dragon
using the formula on page 3 . Long X2 ( horizontal) position remains unchanged. Please note the new location will be lower than the old Y2 Y2 position .

Fire

If you enter this command , then the work of the dragon and the theme is the distance between two points using the first three distances between formulas.
If the distance is less than or equal to the distance of the dragon's flame , then meteorite is destroyed , the corresponding message ( including the name and color of the dragon ) is output to the screen and close the program.

If the distance is greater than the distance from the flame , then the corresponding display information output to the screen, is not destroyed themes guide the user . Program execution continues .

This menu selection does not change the position of the dragon . If the meteorite is not destroyed, and then calculate the new position subject , but Long
remain in the same position .
between


If you enter this command , then the dragon 'between' this time slice . This means that the dragon's position does not change. Subject new location, but calculated .

Tip: This is a very useful command , if the dragon is in the correct position ( horizontal ) , but above the dragon theme , but the flame distance. Dragon 'between' , come back in exactly the same position and topics
has dropped close to Long . Of course, the thread may be blown to the left or right , rather than between the dragon .

exit

If you enter this command, the program ends , the message is not displayed meteorite is being destroyed.

Note : System.exit () is not allowed, the use will result in any significant loss of marks .

program continues to loop around until destroyed themes, themes reach the ground, two cases in which the corresponding message
( including the name and color of the dragon ) is output to the screen , the user enters " quit " command.


Each time through the loop is considered to be a time slice .

Each time through the loop , themes and Long positions should be shown on the screen.

input text file format

line in the file description
Mnementh Long Name
39 Wingspan (INT)
Benden weyr ( can be more than one word )
color bronze dragon
1000 initial Y2 position ( height ) of the Dragon
2000年2 times the initial ( horizontal ) position of the Dragon
200 Flame Long distance

attached below the original English edition

Problem Description and Background
The planet Pern, in a faraway star system, has been settled by humans. Every 200 years or so, Pern is plagued by Thread. Thread comes from outer space and falls through the atmosphere. If Thread reaches the ground then it destroys plants and animals (including humans). The people of Pern have fire breathing dragons, ridden by humans. When Thread falls the dragons and riders rise up into the air and attempt to destroy the Thread before it reaches the ground. If a dragon is close enough to a patch of Thread then its flame completely destroys the Thread.

Dragons come in different sizes, this is based on the colour of the dragon. Bigger dragons have a bigger wingspan which means that they can go up and down faster than smaller dragons. However bigger dragons don't go left or right as well as smaller dragons.

Bigger dragons also have a stronger flame which means they can be further away from Thread when they attempt to destroy it, than smaller dragons, and still succeed.

This is known as the flame distance.

When Thread starts to fall the Dragons (and riders) know that Thread has started to fall, but they don't know ; exactly where. So the dragon starts at a certain location in the sky. When the dragon and rider see the position of the ; Thread then they have to try and fly to the position of the Thread.

The position of Thread is recorded using two co-ordinates, x1 and y1, for example. The x1 (horizontal) coordinate ; is the distance (plus or minus) from some arbitrary point on the ground. The y1 (vertical) coordinate is the height above ; the ground.

The position of the dragon is also recorded using two coordinates, x2 and y2, for example. The x2 (horizontal) ; coordinate is the distance (plus or minus) from the same arbitrary point on the ground as is used for Thread. The y2 (vertical) coordinate is the height of the dragon above the ground.

In the action against Thread the flight is divided up into time slices. In one time slice, Thread falls 100 units or is blown horizontally 100 units left or right. When a dragon carries out a menu choice, this also lasts for the whole time slice.

± means plus or minus

All dragons go left or right using this formula newX = oldX ± ((100 / wingspan) * 50)
to go left makes newX less than oldX so subtract to go right makes newX greater than oldX so add

NOTE: x can be negative

All dragons go up or down using this formula newY = oldY ± (wingspan * 5)
Dragons never crash into the ground, they land, so if newY is negative make it zero
The formula for working out the distance between 2 points is distance = √ (x2 - x1) 2 + (y2 - y1) 2

Thread can go down, left or right.

This is determined randomly which is explained below.

Working out the next position of Thread.

Generate a random number between 0 and 16 (exclusive)

If the random number is 0, 3 or 11
then the new x1 (horizontal) position of Thread is 100 units to the right. the y1 (vertical) position stays the same.

If the random number is 5, 9 or 14
then the new x1 (horizontal) position of Thread is 100 units to the left. the y1 (vertical) position stays the same.

any other number except the ones above means that
the y1 (vertical) position of the Thread is 100 units down the x1 (horizontal) position stays the same.

Program Requirements

You are required to write a program, in Java, to simulate a dragon and rider trying to destroy Thread.

The program starts by reading in values ​​from a text file. The format of the text file is given on page 6. You may assume that the text file is always correct and in the correct format. Your program must not hard code the name of the input file. That is, your program must work with any text file in the correct format.

The values ​​in the text file are stored in local variables, one for each line of the file input, see page 6 for the full explanation.

Then the initial position of Thread is generated.

The x1 (horizontal) position is generated by a random number between 0 and 4000 (exclusive)

The y1 (vertical) position is generated by a random number between 1000 and 2000 (exclusive)

After the text file is read in, and the initial position of Thread is generated, the user is presented with a menu. The user then enters commands until the dragon either successfully destroys Thread, Thread reaches the ground or the user enters the " quit "command

Commands must be case insensitive. That means that the commands lefT and LEft
must have the same result.

Shown below is an example of the menu (note, you can customize the menu, but the commands that are entered must ; be text, and must be able to handle a command of more than one word)

Menu

left - Go left right - Go right up - Go up
down - Go down
flame on - breathe fire between - go between quit
Enter choice >>

Commands that can be entered and an explanation of each command

left

If the user enters this command, then the new x2 (horizontal) position of the dragon is worked out using the formula ; on page 3. The y2 (vertical) position of the dragon remains the same. Note that the new x2 position will be less than the old x2 position.

right

If the user enters this command, then the new x2 (horizontal) position of the dragon is worked out using the formula ; on page 3. The y2 (vertical) position of the dragon remains the same. Note that the new x2 position will be greater than the old x2 position.

up

If the user enters this command, then the new y2 (vertical) position of the dragon
is worked out using the formula on page 3. The x2 (horizontal) position of the dragon remains the same. Note ; that the new y2 position will be greater than the old y2 position.

down

If the user enters this command, then the new y2 (vertical) position of the dragon
is worked out using the formula on page 3. The x2 (horizontal) position of the dragon remains the same. Note ; that the new y2 position will be less than the old y2 position.

flame on

If the user enters this command, then the distance between the dragon and Thread is worked out using the formula for the distance between 2 points on page 3.
If this distance is less than or equal to the flame distance of the dragon, then the Thread is destroyed, an appropriate message (which includes the name and colour of the dragon) is output to the screen and the program closes.

If the distance is greater than the flame distance then an appropriate message is output to the screen advising the user that the Thread was not destroyed. The program continues.

This menu choice does NOT change the position of the dragon. If Thread is not destroyed then the new position of Thread is calculated, but the dragon
stays in the same position.

between

If the user enters this command then the dragon "goes between" for this time slice. This means that the position of the dragon does not change. The new position of Thread is, however, calculated.

Hint: this command is useful if a dragon is in the right position (horizontally) but Thread is above the dragon, ; but out of flame distance range. The dragon can "go between", come back in exactly the same position and Thread will
have dropped down closer to the dragon. Of course, Thread may be blown left or right instead of going down while the dragon was between.

quit

If the user enters this command, the program ends, without displaying a message about whether or not Thread was destroyed.






------ Solution ------------------------------------ --------
me that all watching . Thread I do not know what should be translated into ? Know and what I say next .

I probably said that under the background of it, is to have a Thread that fell outside of Pern from the atmosphere on the planet , and then people on Pern has a very fast hardware mounts, fire-breathing dragon ( Nima really fast hardware ) . Then they 'll ride this fire-breathing dragon to go to Thread melt away , fell to the ground before the Thread .

procedures require that a console input commands manipulate virtual dragon to melt Thread. Each instruction is mainly for the operation coordinate what quantity .
not clear in some places that look page6, there should be a book . Electronic files should all foreign materials, you only made one such request , others simply can not help you .

Ps: I was more bored, so a reading article. . . Landlord, if it will not do, add my QQ bar. 392190627 . Studying abroad is really not easy.
------ For reference only -------------------------------------- -
amount . . . Good looks complicated , it will not, and continue to onlookers !
------ For reference only ---------------------------------------
can not use google translate it ?
------ For reference only -------------------------------------- -
less playing the Three Kingdoms , see more java, will write a
------ For reference only -------------------- -------------------
Well, to see such a long title , I was directly pull the scroll bar
------ For reference only ---------------------------------------
this translation is a good one. . .
------ For reference only -------------------------------------- -
you do not learn Java Yes, even these students go abroad every Google Translate English what kind of strength is also mixed .
------ For reference only -------------------------------------- -
Why Chinese version but can not see understand. . .
------ For reference only -------------------------------------- -
FML , this Chinese Translator ... I ... I started to feel very smooth in English
------ For reference only ---------------------------------------
 English. .
------ For reference only -------------------------------------- -
  The reply deleted by an administrator at 2013-09-25 10:16:13

------ For reference only ---------------------------------- -----
this translation . .
------ For reference only ---------------------------------------
said that did not understand, do not bother Kane.
------ For reference only -------------------------------------- -
  The reply deleted by an administrator at 2013-09-25 16:33:36

------ For reference only ---------------------------------- -----
indicates that the content for a long ~
------ For reference only ------------------------- --------------
this is the game you ?
------ For reference only -------------------------------------- -

---- - For reference only ---------------------------------------
Tete Mody long +
------ For reference only ----------------------------------- ----

- ----- For reference only ---------------------------------------

Chinese , English can not read how to do , a quick look at the story as
------ For reference only --------------- ------------------------
English no, Chinese do not understand
------ For reference only --------------------- ------------------
you Ah ah ass with a software translator
------ For reference only -------- -------------------------------
this is God horse stuff , ah, too deep right
- ---- For reference only ---------------------------------------
< br /> you're bored. . . Another Thread proposal transliterated as " feces come "
------ For reference only ---------------------------- -----------

you really boring. . . Another Thread proposal transliterated as " feces come ."  
disgusting . .
------ For reference only ---------------------------------------
good fast hardware , a good high-end like ah
------ For reference only ------------------------------------ ---
English lot, Mo Kanwan . Chinese Good complicated read.
------ For reference only -------------------------------------- -
abroad flow problem is to force ! !
------ For reference only -------------------------------------- -
this Chinese translation has been through six orifices ! really powerful

没有评论:

发表评论