Another Java App.

 

Home Forums Global Off topic Another Java App.

This topic contains 3 replies, has 3 voices, and was last updated by  DragonEngineer 8 years, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #118553 Score: 0

    Spy
    Participant

    This time I made a calculator, and it adds any two numbers together.

    View post on imgur.com

    • This topic was modified 8 years, 9 months ago by  Spy.
    #118623 Score: 0

    DragonEngineer
    Participant

    Good luck in becoming better in Java.

    Once you are better at it, you can try…
    – Solve quadratic equation with gradient at a certain point

    View post on imgur.com

    and…
    – A game
    (In this example it is a game of survival using basic concepts like repetitions, selections, arrays and methods and parameters)

    View post on imgur.com

    Rules for the game of Survival

    Two clans are stranded on opposite ends of an island in the Pacific Ocean. It has been about one week since they both arrived at the island mysteriously. Through some fortune both clans have discovered a plot of land in the middle of the island overflowing with resources. The land is a 10 x 10 region, where each element has one type of hidden resource.

    The hidden resources are (1) food, (2) weapons, (3) medical supplies and (4) clean water. Each clan will send one representative to play this game.
    The simplified game of Survival is a two-player game played on a 10 x 10 game board. The objective of the game is for each clan to gather as many resources to determine who will survive the longest on the island. The winner is the player who has the most number of resources, in terms of points. This modified version of Survival will be simulated using two computer players.

    No user input is required for this game. The 10×10 board will be simulated using a 10 x 10 2D array. At the start, the game must randomly decide which computer player (1 or 2) will go first.

    This game will include the following pieces:
     “food” piece – represents one food resource
     “weapons” piece – represents one weapons resource
     “medical supplies” piece – represents one medical supplies resource
     “clean water” piece – represents one clean water resource

    For this game the program should randomly hide 15 pieces of each resource across the 10 x 10 grid. Assume only one resource can be placed inside each box of the grid. The game begins by generating a random number between 25 and 100, inclusive which indicates the total number of turns (i.e. player 1 and player 2 combined) to take.

    Then, the program should simulate the game play as follows:

     At each turn, the current state of the game board should be displayed and which resources have been taken by a computer player (player 1 or 2);

     At each turn the program must also generate two random numbers, each between 1 and 10, inclusive that represent the x and y position in the 2D array.

     The rules for placing an item on the game board are as follows:
    If the two random numbers total up to 0, 10 or 18, then the player has the choice to denote the area around that [x][y]. The choice depends on another random number between 1 and 2, inclusive. If the random number is 1, then the detonation will happen. Otherwise, no detonation occurs, the resource can be assigned to the player’s inventory and the game board is updated.

    The area around the [x][y] for detonation is the immediate 8 neighbours of the [x][y] position. Denotation means that all resources in those 8 immediate neighbours will be destroyed such that no computer player can acquire them now or in the future.

    For any other dice value, the program should check the [x][y] position. If there is a resource available there it should be assigned to the computer player’s inventory and the game board is updated.

    If the [x][y] position on the game board has no resource, the computer player skips its turn.

    Overall, each position (or slot) in the displayed 10×10 2D game board can contain any of the following:
     E  empty space
     F  food resource
     W  weapons resource
     M  medical supplies resource
     C  clean water resource

    Every time a resource is assigned to the inventory of one of the computer player’s points are assigned as follows:

    Food – 45 points
    Weapons – 25 points
    Medical supplies – 25 points
    Clean Waters – 50 points

    The game ends when the following condition is satisfied:
     When there are no more remaining resources to find on the game board. At this point, your program should go through the game board identify the winner.

    How to win (In order of priority)
    1: One player has 25% more clean water resources than the other player
    2: One player has 35% more medical supplies resources than the other player
    3: The player with the most points

    The program should print a “Tie” if both computer players end up with the same number of points based on their inventory.

    Though those are in C++, it is possible with Java. In fact, for the Survival game, it was one of my programming assignment, for both C++ and Java users

    #118628 Score: 0

    TheHighOreo
    Participant
    1 pt

    Ewwww nerd alert!

    #118635 Score: 0

    DragonEngineer
    Participant

    The 2nd one sometimes is buggy

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

 Posted by at

Sorry, the comment form is closed at this time.

Do NOT follow this link or you will be banned from the site!