Blue Gold World Water Wars

Ein weiterer toller swissblog.ch Blog

Last Exit – DivX Version (Normal Quality), DVD (Good Quality), PDA Version

Posted by petercarney1978 on 21. November 2009

Last ExitLast Exit (2006)

IMDB rating: 6.20

Plot: Shattered windshields. Twisted wreckage. Last Exit is an action-suspense drama that tells the parallel stories of two ordinary women – one, a single mother barely supporting her handicapped son, and the other, a working mom precariously balancing her family with a high-pressure career – on one extraordinary day. Each woman’s life frays under the weight of her circumstances and spirals out of control. As police officers race to save them, pieces of a shattered puzzle fall into place – maybe this wasn’t just a tragic car accident after all. Both women fight for their lives, but ultimately, only one will survive

Download

Available versions:

DivX Version (Normal Quality), DVD (Good Quality), PDA Version

Directors: Fawcett John

Actors: Post Tim,Ashby Linden,Action,Drama

Download Full Version>>

java question about sorting…?
ok I’m just a beginner with this crap…

But I’m making a project right now for one of my classes

And I’m confused. I’m trying to sort an undefined amount of people in an array into order from highest to lowest score, depending on their score in a game from the last round, but the only way i can figure out to do this is by switching around the actual values assigned to the array which works fine until it comes to the next round of play because then the players turns are also switched around. and i need them to remain the same throughout. And I use their orders in the array to give them the turns.

(note that there is not a defined amount of players, it could be any number)

here is my code so far (3 parts):

MAIN (NARF) CLASS:
public class Narf
{
public static String playGame(int players)
{
Player[] p = new Player[players]; //player number

for (int z = 0; z < p.length; z++)
{
System.out.println("What is player " + z + "’s name?");
String name = StdIn.readString();
p[z] = new Player(name);
}

for ( int counter=1; counter < 7; counter ++)
{
System.out.println("Round " + counter);
for (int i = 0; i < p.length; i++)
{
p[i].playRound(counter);
}
System.out.println("The scores after Round " + counter + " are:");
Player.arrangeScores(p);
}
return p[0].name;

}
public static void main(String[] args)
{

int play = 0; //int to play or quit

do{
System.out.println("Would you like to play again?");
System.out.println("Enter a number for the number of players to play or 0 to quit:");
play = StdIn.readInt(); //enter number to play or quit game

//play game
if (play > 0)
{
String winner = playGame(play);
}

//exit game
if (play == 0)
{
System.out.println("GOOD-BYE!");
}

if (play < 0)
{
System.out.println("Entry not valid.");
}
}while(play != 0);
}
}

PLAYER CLASS:
public class Player
{
public int score;
public Dice playerDice;
public int times =0;
public int roundScore=0;
public String name = "";

public Player(String pname)
{
score = 0;
name = pname;
}

public static void arrangeScores(Player[] p)
{
//arranges scores in order
for(int x = 0; x < p.length; x++)
{
Player[] temp = new Player[1]; //hold temp value
for (int a = 1; a < p.length; a++)
{
if (p[a - 1].score < p[a].score)
{
temp[0]= p[a-1];
p[a-1] = p[a];
p[a] = temp[0];
}
}
}

for (int x = 0; x < p.length; x++)
{
System.out.println(x+1 + ") " + p[x].name + ": " + p[x].score + " points.");
}
}

public void playRound(int round)
{
playerDice = new Dice(round);
int diceToRoll = 6;

int scoredice = 0;
int choice = 1;
int cumulativeDice =0;
while( times <3 && choice ==1 ) //keeps going while user wants it to or until the dice are rolled three times
{
if(playerDice.rollDice(diceToRoll))
{
scoredice=playerDice.scoringDice(diceToRoll, round);
System.out.println("Score before this round: " + score);
cumulativeDice = cumulativeDice + scoredice; //will give the total amount of dice to be scored at the end
roundScore = playerDice.calculateScore(round, cumulativeDice);
System.out.println("Score for this round after " + (times+1) + " rolls: " + roundScore);
}
else
{
System.out.println("You Narfed!");
roundScore = 0;
break; //stops loop and gives the total round score as 0
}
times ++;
diceToRoll= diceToRoll – scoredice; //subtracts the number of scoring die from 6
if(times < 3)
{
System.out.println("Would you like to roll your remaining " + diceToRoll + " again? (1 for yes, 0 to bank your score)");
choice = StdIn.readInt(); //allows user to continue the round or take the score they have
}
}
times =0;

score += roundScore; //gives the total score for the round
System.out.println("Total score after round " + round + ": " + score);

if(round ==6)
{
System.out.println("Your final score is: " + score); // will print out the final score at the end of round six
}
}

}

DICE CLASS:
public class Dice
{
public int round;
public int [] dice;
public int count =0;

public Dice(int roundNumber)
{
round=roundNumber;
dice = new int[6];
}
//will print out the dice and then determine whether the player has "Narfed" or not
public boolean rollDice(int amountToRoll)
{
boolean returnvar = fal


Hey man. Keep up the good work. Here’s an example.

public class Game {

//arraylist of players
ArrayList<Player> players = new ArrayList();
public static void main(String[] args) {
Game g = new Game();
g.letsGo();
}

public void letsGo() {
//i’m just generating some random values
Random r = new Random();
for(int i = 1; i < 20; i++) {
players.add(new Player(i, new Double(r.nextDouble() * 50).intValue()));
}

//here we create an array for the sorted values
Player[] sortedByPoints = new Player[players.size()];
players.toArray(sortedByPoints);

//now sort our sortedByPoints array
Arrays.sort(sortedByPoints);

//here you can see how sortedByPoints has everyone sorted by points
//and players still has everyone sorted by position
for(int i = 0; i < sortedByPoints.length; i++) {
System.out.println("Player " + sortedByPoints[i].position + " has " + sortedByPoints[i].score + " pts." +
" " + "Position " + players.get(i).position + " has " + players.get(i).score + " pts ");
}
}

//this is very key. implements Comparable allows you to do a sort
public class Player implements Comparable {

int score = 0;
int position = 0;

public Player(int pos, int sc) {
position = pos;
score = sc;
}

//must implement this abstract method and define how the objects
//should be compared
@Override
public int compareTo(Object o) {
return ((Player)o).score – this.score;
}

}
}
conventional | Nov 19, 2009

Leave a Reply



XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>