Preview

zxcv

Good Essays
Open Document
Open Document
2263 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
zxcv
Object-Oriented Design
The Game of War
Illustrate the process of designing an object-oriented solution to a small problem by simulating War, a twoperson game for children that uses a deck of playing cards. The rules of the game act as an initial specification of the problem. A card deck consists of 52 playing cards, each of which has a numeric value between 1 and 13, called the rank of the card, and one of four suits (clubs, diamonds, hearts, and spades).
The values 1, 11, 12, and 13 have special names: ace, jack, queen, and king, respectively.
To play the game we deal the entire deck of cards to two players.
Each player has a pile of 26 cards face down on the table. During a turn of the game, the players show the top cards from their piles, and the player with the higherranking card wins both of the cards, putting them faceup in a pile.
For the purpose of comparison, aces count as highest.
If the cards shown by the players have the same rank, each player places the number of cards equal to that rank face down on the table.
Copyright 2004 by Ken Slonneger

Object-Oriented Design

1

The last cards played by each player are turned over and compared.
The higher value wins all of the cards that have been played this turn.
If another tie occurs, the process is repeated.
When a player finishes playing all of the cards in his or her playing pile, the cards won in previous turns are turned over and become a new playing pile.
If either player cannot complete a turn for lack of cards, the other player wins the game.
The goal of this program is to simulate the playing of a game of War with two players, named Ernie and Burt.

Analysis
After reviewing the specification of the problem, several points need clarification.
1. Implied in the game is the fact that we need to shuffle the deck of cards before the cards are dealt to the players. 2. Note that each player has two piles of cards: The pile of cards from which the player

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Rvrvev

    • 397 Words
    • 2 Pages

    8. Calcareous ooze is associated with ________ surface water conditions, and siliceous ooze is associated with ________ surface water conditions.…

    • 397 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    amount of time. Each player will start with $1,000 and will draw a card to determine their…

    • 974 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Arapaho History

    • 603 Words
    • 3 Pages

    According to the “Moccasin Game History,” this game can date back to late 1700’s or early 1800’s. Once upon time, there are two hunter warriors hunting meat for the winter. However, two hunter warriors saw the elk together. These two hunter warriors were from different tribes with different language and culture, and sometimes they argued with each other about the land and hunting right. They were aware of that there would be lots of blood if the battles start. Therefore, one of the hunters suggested that play a game to decide the winner, and the winner could take everything from the loser, even his life. “But after playing this game for a long time, the two warrior hunters became friends and agreed that this was the way they should settle future disputes. But after playing this game for a long time, the two warrior hunters became friends and agreed that this was the way they should settle future disputes.” After reading this history, I felt respect for the warrior hunter’s wisdom and thought about the war happened in our earth. Many countries battle each other because of natural resources or territory. Many innocent people and children lose their families and home, even life through the war. Why the governor cannot solve the problem peaceful?…

    • 603 Words
    • 3 Pages
    Good Essays
  • Good Essays

    The teams were Justin and Bobby against me, Tyler, and Paul. This game always ended in defeat for my team, partly because we were inferior at throwing, and partly because Justin and Bobby would shove rocks into their dirt clods. At night, we would run inside, eat something, and run downstairs to play, “War in the Dark.” This was just pure chaos. The rules went as follows: every ball in the house would be dumped in the basement, the lights would be turned off, and we would throw balls at each other until we were too tired to continue. We would finish the night by turning on Bobby’s favorite movie, Gettysburg, and drift off to sleep. After successfully defending the Union’s position, General Buford triumphantly declares, “General Reynolds, we’ve held the high ground.” (Maxwell). This line may seem insignificant, but still to this day, after any small success, we’ll turn to each and say, “General Reynolds, we’ve held the high…

    • 931 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Nvq3

    • 441 Words
    • 2 Pages

    |safeguarding or protection of individuals |individuals, their friends and family and their property. To help them keep | |…

    • 441 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    In my classroom, I would have my students play a game that is called “Toddler Kickball.” Throughout the course of the game, I will incorporate several facets of the activity that are helpful to the entire classroom, yet does not make Philip feel different or excluded. The step-by-step setup of the activity are as follows:…

    • 1082 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Cda Learning Experiences

    • 323 Words
    • 2 Pages

    Implementation: This game will be available for the children during free play time. It will be sitting in the black tub, on the shelf and available for the children to play with. The children can take it off the shelf and play with it on the table. This can be a multiple player game. Shuffle the deck. One player will deal the cards one at a time until all cards are dealt. Each player will look at their hand. Discard all matching pairs of cards face up in front of you. The player to the left of the dealer then offers their hand to the player on their left. This player takes one card from the offered hand and lays down any pair of matching cards that may be found. Play continues with this player offering cards that may be formed. One player will be left in the end with the old maid card who does not have a match. The teacher will be available to help the children match the cards, helping take turns, and asking questions like: * “How many cards do you have left?” * “I wonder who is going to end the game with the old maid?”…

    • 323 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    nvq3

    • 14317 Words
    • 81 Pages

    UNISON duty of care handbook For members working in health and social care ‘‘ At a time of change, patients and service users depend more than ever on the integrity of care professionals. This handbook is a valuable guide to health and care professionals’ responsibilities and rights, and to sources of help when it may be hard to know the right thing to do and even harder to do it. ‘‘ Harry Cayton, chief executive, Council for Healthcare Regulatory Excellence ‘‘ Safeguarding the public and delivering high quality patient care are essential. Key to this is creating a culture where nurses and midwives are able to appropriately raise concerns, particularly in a time of significant structural change across health care organisations. This handbook is a useful supplement to the Code and other NMC standards and guidance which specify the responsibilities of nurses and midwives in raising and escalating concerns.…

    • 14317 Words
    • 81 Pages
    Powerful Essays
  • Powerful Essays

    Nvq3

    • 1325 Words
    • 6 Pages

    - Revised legislation for physical punishment, it is now an offence to hit a child if it causes mental harm or leaves a lasting mark.…

    • 1325 Words
    • 6 Pages
    Powerful Essays
  • Good Essays

    Msfjnv

    • 892 Words
    • 4 Pages

    Describe the expected pattern of children and young people's development from birth to 19 years, to include:…

    • 892 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Learning and Young Person

    • 870 Words
    • 3 Pages

    There are numerous games you can play with a child, young person in almost any environment and at any time, such as……

    • 870 Words
    • 3 Pages
    Good Essays
  • Good Essays

    zxczxczxczzczxcz

    • 511 Words
    • 2 Pages

    It is common knowledge that Web server application attacks have become common in today’s digital information sharing age. Understanding the implications and vulnerabilities of such attacks, as well as the manner in which we may safeguard against them is paramount, because our demands on e-Commerce and the Internet have increased exponentially. In this assignment, you will examine the response of both the U.S. government and non-government entities to such attacks.…

    • 511 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    ZINGPC

    • 4041 Words
    • 12 Pages

    In April 200X, Zippy Computer, Inc., merged with Binger International, Ltd. The new entity was named Zinger Electronics, Inc. and began trading on the NASDAQ. Zinger Electronics, Inc., produces a variety of high-tech goods and services—computers and servers, Internet services, Web hosting, and business-to-business e-commerce applications. Their award-winning computers are sold under the ZingPC brand to business, government, education, and consumer markets.…

    • 4041 Words
    • 12 Pages
    Powerful Essays
  • Satisfactory Essays

    Zxccdvgsg

    • 648 Words
    • 3 Pages

    French spy agency tries to pull 'classified' Wikipedia entry, only draws more attention to it…

    • 648 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Vcxzg

    • 480 Words
    • 2 Pages

    When a life threatening incident happens you can be scarred physically and live with stress. The perfect remedy for curing physical pain and stress is acupuncture. Acupuncture was used in ancient china by the Taoist and has been scientifically proven to reduce stress and chronic pain. Acupuncturist believe that pain and illness result from the disruption of the energy flow in the body and use various methods such as needling and herbal remedies to return the body back into its natural balance.…

    • 480 Words
    • 2 Pages
    Good Essays