GithubHelp home page GithubHelp logo

week6assignment's Introduction

Instructions: In Eclipse, or an IDE of your choice, write the code that accomplishes the objectives listed below. Ensure that the code compiles and runs as directed. Take screenshots of the code and of the running program (make sure to get screenshots of all required functionality) and paste them in this document where instructed below. Create a new repository on GitHub for this week’s assignments and push this document, with your Java project code, to the repository. Add the URL for this week’s repository to this document where instructed and submit this document to your instructor when complete. Coding Steps: For the final project you will be creating an automated version of the classic card game WAR.

  1. Create the following classes. a. Card i. Fields
  2. value (contains a value from 2-14 representing cards 2-Ace)
  3. name (e.g. Ace of Diamonds, or Two of Hearts) ii. Methods
  4. Getters and Setters
  5. describe (prints out information about a card) b. Deck i. Fields
  6. cards (List of Card) ii. Methods
  7. shuffle (randomizes the order of the cards)
  8. draw (removes and returns the top card of the Cards field)
  9. In the constructor, when a new Deck is instantiated, the Cards field should be populated with the standard 52 cards. c. Player i. Fields
  10. hand (List of Card)
  11. score (set to 0 in the constructor)
  12. name ii. Methods
  13. describe (prints out information about the player and calls the describe method for each card in the Hand List)
  14. flip (removes and returns the top card of the Hand)
  15. draw (takes a Deck as an argument and calls the draw method on the deck, adding the returned Card to the hand field)
  16. incrementScore (adds 1 to the Player’s score field)
  17. Create a class called App with a main method.
  18. Instantiate a Deck and two Players, call the shuffle method on the deck.
  19. Using a traditional for loop, iterate 52 times calling the Draw method on the other player each iteration using the Deck you instantiated.
  20. Using a traditional for loop, iterate 26 times and call the flip method for each player. a. Compare the value of each card returned by the two player’s flip methods. Call the incrementScore method on the player whose card has the higher value.
  21. After the loop, compare the final score from each player.
  22. Print the final score of each player and either “Player 1”, “Player 2”, or “Draw” depending on which score is higher or if they are both the same.

week6assignment's People

Contributors

zmontoya94 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.