Data structures and algorithms in C++
Data structures and algorithms in C++
2nd Edition
ISBN: 9780470460443
Author: Goodrich
Publisher: WILEY
bartleby

Videos

Question
Book Icon
Chapter 2, Problem 4P
Program Plan Intro

Collision of animals

Program plan:

  • Declare header file.
  • Declare namespace.
  • Create a class “Animal”,
    • Declare public access modifier.
    • Declare the default and parameterized constructor and public member functions.
    • Declare the necessary private member variables.
  • Define the default constructor to set the default values for the member variables.
  • Define the parameterized constructor to set the argument values to the variables.
  • Define the method “get_Type()” to return the type of animal.
  • Define the method “get_Gender()” to return the gender of animal.
  • Define the method “get_Strength()” to return the strength of animal.
  • Define the method “print_Animal()” to print the details of animal,
  • Define the method “collide1()”,
    • Create a new animal.
    • Call the method “print_Animal()” to print the details of animal.
    • Check whether the two animals are of same type,
      • If it is true check whether they are different gender,
        • If it is true, set the type.
        • Set the random gender.
        • Set the random strength.
        • Create new animal and print the details of animal.
      • Otherwise, check whether they have different strength,
        • If it is true, print the message and return the new animal.
      • Otherwise,
        • Print another corresponding message and return the new animal.
          • Otherwise,
            • Print corresponding message and return new animal.
  • Declare the method “printAll_Animals()”.
  • Define the method “main()”,
    • Initialize the random number generator.
    • Create vector of animals.
    • Create instances for Animal class.
    • Insert the instances into the vector.
    • Call the method “printAll_Animals()”.
    • Check whether there is empty type,
      • Insert into the vector.
      • Call the method “printAll_Animals()”.
  • Define the method “printAll_Animals()”.
    • Print the heading.
    • Execute till vector size,
      • Call the method “printl_Animal()”.
      • Print new line.

Blurred answer
Students have asked these similar questions
Given the following Extended-BNF grammar of the basic mathematical expressions:  Show the derivation steps for the expression: ( 2 + 3 ) * 6 – 20 / ( 3 + 1 ) Draw the parsing tree of this expression. SEE IMAGE
Whentheuserenters!!,themostrecentcommandinthehistoryisexecuted.In the example above, if the user entered the command: Osh> !! The ‘ls -l’ command should be executed and echoed on user’s screen. The command should also be placed in the history buffer as the next command. Whentheuserentersasingle!followedbyanintegerN,theNthcommandin the history is executed. In the example above, if the user entered the command: Osh> ! 3 The ‘ps’ command should be executed and echoed on the user’s screen. The command should also be placed in the history buffer as the next command. Error handling: The program should also manage basic error handling. For example, if there are no commands in the history, entering !! should result in a message “No commands in history.” Also, if there is no command corresponding to the number entered with the single !, the program should output "No such command in history."
Activity No. Activity Time (weeks) Immediate Predecessors 1 Requirements collection 3 2 Requirements structuring 4 1 3 Process analysis 3 2 4 Data analysis 3 2 5 Logical design 50 3,4 6 Physical design 5 5 7 Implementation 6 6 c. Using the information from part b, prepare a network diagram. Identify the critical path.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY