Interaction in a tic-tac-toe game

Assignment Help Database Management System
Reference no: EM131224581

Your assignment should be submitted in a single Word doc (.doc or .docx). It should include your scenario diagram for Problem 1, and your Ruby source code for Problems 2 and 3. Contact me or post to our discussion board if you have any questions concerning this assignment. Note that, per the course syllabus, no submission will be accepted past the due date.

This assignment asks you to use scenario diagrams to think about the interactions between objects, and explores Ruby a bit further.

Problem 1:

Here is an interaction in a tic-tac-toe game, with user input in bold:

>> gm = Game.new('andy', 'mike')
=> #<Game:0x2e91d78 @players=[Andy, Mike]>
>> gm.play_game('mike')
Mike, enter your next O move (1-9): 1
O - -
- - -
- - -
Andy, enter your next X move (1-9): 3
O - X
- - -
- - -
Mike, enter your next O move (1-9): 5
O - X
- O -
- - -
Andy, enter your next X move (1-9): 3
Bad move dude! You go again. O - X
- O -
- - -
Andy, enter your next X move (1-9): 6
O - X
- O X
- - -
Mike, enter your next O move (1-9): 9
O - X
- O X
- - O
Mike, you won!
=> nil
>> gm.play_game('karen')
I don't know that player. Please try again.
=> nil

>> gm.play_game('andy')
Andy, enter your next O move (1-9): 5
- - -
- O -
- - -

When a new game is created, two players register with it by name (the arguments to Game.new). The play_game message is called with one of the player's names and starts a new game where that player plays first using the O marker. (A game can be sent repeated play_game messages so the same pair of players can play multiple games). In each iteration, the current player is prompted for the position of her move and then she enters the move number, where the nine squares are numbered in row-major order from 1 through 9. If a move is illegal (i.e., already occupied), the current player is scolded and prompted again for a move. After each move, the board is redrawn. A game ends when either one of the players forms a horizontal, vertical, or diagonal row of her three markers (in the usual way), or the board is full indicating a tie.

The assignment is not to implement this game in Ruby. Rather, the assignment is to use scenario diagrams to discover the objects, their responsibilities, and the messages they respond to.

Specifically, focus on the scenario of a typical iteration: If the current game is not over, the current player is prompted for a legal move which she supplies and then the move is made and the current game board is displayed. Hand in a single scenario diagram that you believe represents your best design. You can use whatever tools you want to create this diagram including the online tool at https://www.websequencediagrams.com/ which I use for my scenario diagrams.

Problem 2

A DNA strand is represented by a string of the characters A, C, G, and T, each of which represents a nucleotide. Each nucleotide has its complement as indicated by this Ruby hash:

NUCLEOTIDE_COMPLEMENT = {
'A' => 'T', 'T' => 'A', 'C' => 'G', 'G' => 'C'
}

The reverse-complement of a DNA string is a new string in which each nucleotide is replaced by its complement and the string is reversed. Reverse-complements are important in bioinformatics since a strand of DNA can be read in forward direction or, equivalently, its complementary strand can be read in its forward direction, which is reverse of the original string's direction. Add the reverse_complement method to your DNA class. In response to reverse_complement, it returns a new DNA instance representing its reverse-complement. Note also that a == b if and only if DNA instances a and b represent the same DNA strand.

>> dna1 = DNA.new('ATTGCC')
=> ATTGCC
>> dna2 = dna1.reverse_complement
=> GGCAAT
>> dna2
=> GGCAAT
>> dna1
=> ATTGCC
>> dna2.reverse_complement
=> ATTGCC
>> dna1.reverse_complement.reverse_complement == dna1
=> true

Problem 3

Write a PhoneContact class that gets initialized with a phone number and a label. The phone number should follow one of the formats of the Phone class from the previous assignment (and you should use the Phone class in this assignment). A label is either a symbol or a string. A phone contact responds to the label, phone_number, and to_s messages. Note that phone_number returns a Phone object:

>> contact1 = PhoneContact.new('(954) 555-1212', :work)
=> (954) 555-1212 (work)
>> contact1.label
=> "work"
>> contact1.phone_number
=> "(954) 555-1212"
>> contact1.to_s
=> "(954) 555-1212 (work)"
>> contact2 = PhoneContact.new(' 955-555-1212', "cell")
=> (955) 555-1212 (cell)
>> contact2.phone_number.area_code
=> 955

Reference no: EM131224581

Questions Cloud

Calculate the labor force participation rate : In the economy of Macroland 60.3 percent of the population is employed, while the unemployment rate is 8.0 percent. Calculate the labor force participation rate.
What makes the person or organization stand out : There are leaders in every field of study and business around the world. Select a business leader you admire. Use your textbook, the Argosy University online library resources, and the Internet to select a leader and then to research the leader's ..
What about special pricing for some markets or customers : What about special pricing for some markets or customers? Show effect on revenues and profitability based on stated assumptions. Potential advantages and disadvantages, both financial and non-financial.
Calculate the income elasticity of demand : Calculate the income elasticity of demand for this good at the point from part d).  Is good X normal or inferior? Calculate the effect of a 3.5 percent decrease in income on the demand for good X (all other demand factors being held constant and pr..
Interaction in a tic-tac-toe game : Write a PhoneContact class that gets initialized with a phone number and a label. The phone number should follow one of the formats of the Phone class from the previous assignment (and you should use the Phone class in this assignment).
Determine the percentage of mass transfer resistance : ENSC3019 Assignment - Mass Transfer and Absorptions. Water is used to absorb the vapor of methanol at 300 K and 101.325 kPa. The concentration of methanol in both gas and liquid phases are very low, with the equilibrium relation following Henry's L..
Prepare an income statement and balance sheet : Formulating Financial Statements from Raw Data . -  Prepare an income statement, balance sheet, and statement of cash flows for General Mills, Inc.
What is a managerial accounting model : How can we reconcile the two statements? What is a managerial accounting model? Read the article and comment on some aspect of the discussion in an attempt to shed some light on this topic. What are your thoughts at this juncture?
Recruitment process and the selection process : What are the differences (if any) between the recruitment process and the selection process? In what ways are they interchangeable and dependent on each other?

Reviews

Write a Review

Database Management System Questions & Answers

  What is a data warehouse and why is rei building one

What is a data warehouse and why is REI building one and What are some of the risks or concerns surrounding the creation of a data warehouse

  An art museum that needs to track the artwork artists and

write a 750- to 1050-word paper in which you complete the followingmiddot choose a database environment from the

  Improve decision making for management

Prepare a brief of at least 1,400 words for Kudler Fine Foods management in which you address

  Add a validation rule for date of birth

Make an Update Query that will add the phrase "Free Champagne for this Preferred Guest" to the Comments field, but only if the guest stays for 8 days or more.

  Implemented a consolidation strategy

A prestigious university has recently implemented a consolidation strategy that will require it to centralize their student records. In order to move forward, the local university will need to develop a data model that will retain student records ..

  Design pattern for web based database interfaces

We have implemented the MVC design pattern for Web based database interfaces. However, there are other design patterns that may be directly applicable to PHP programming, or web programming in general.

  Create set of relational tables that are normalized to bcnf

Using the information given above, create a set of relational tables that are normalized to BCNF.

  Question 1 consider the relational schemapartpart-id name

question 1. consider the relational schemapartpart-id name costsubpartpart-id subpart-id counta tuple p1 p2 3 in the

  Explain the security mechanisms available for a database

Use technology and information resources to research issues in database systems. Write clearly and concisely about relational database management systems using proper writing mechanics and technical style conventions.

  How much total materials handling cost would be allocated

how much of the total materials handling cost would be allocated to the prefab barns and how much of the total materials handling cost would be allocated to the modular homes?

  Use a database to answer questions about scholarships

In this project, you will use a database to answer questions about scholarships awarded to students at a college. You will create a relationship between two tables, create a query from an existing query, and create queries using text, numeric, com..

  What kind of a design would you try in this case

Suppose that your database system has very ine?cient implementations of index structures. What kind of a design would you try in this case?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd