Hello all! I'm reposting the week 5 quiz...this time with questions for Chapter 11 and an EXERCISE at the bottom!
Greetings All!
It's once again
QUIZ TIME!!! That's right, listed below are a set of quiz questions to help you test your knowledge and understanding of the material contained in chapters 6 and 11.
In addition to the questions and exercises below, make sure that as you're reading the book you enter the examples into your compiler, build the program, and run the executable. I know this is a time consuming process, but the repeat use of keywords, syntax, and semantics will help ingrain the information into your long-term memory. My advice is to create a simple "driver" project with a function main. As you read, enter the examples into function main, test it, and then erase it for use again in the next example.
PLEASE DO NOT POST THE ANSWERS TO THESE QUESTIONS OR EXERCISES. If you are unable to answer these questions, please ask for assistance, but
DO NOT POST THE ANSWERS. Any question which is not marked with
[Extra Credit] can be answered by reading your textbook. Questions which are marked
[Extra Credit] either have been answered in the thread previously, or can be answered by doing a bit of research.
I will create an answer thread for these questions immediately, so that people will have a chance to get the answers more quickly.
Chapter 6 Quiz1. What was the ‘C’ capability which allowed you to combine related variables? Did this solve the problem of connecting data with behaviors?
2. How do you make a new type in C++?
3. What is a class?
4. What is another name for variables within a class? What is another name for the member functions?
5. What are the requisite parts of a class declaration? Show an example.
6. What are the two things a class declaration tells your compiler?
7. When discussing naming conventions, what’s the most important point to remember?
8. What is an object?
9. How do you declare an object? Show an example.
10. What operator is used to access members and methods of a class for objects created on the stack.
11. What is the difference between public and private members/methods within a class? Which is the default?
12. In general, should methods or members be private? Why?
13. What is the primary way you initialize the member data of a class?
14. How can you identify a constructor for a class?
15. What is a default constructor? How is it called.
16. What does “declaring a method of a class const” mean? What is the syntax for such a declaration?
17. In the context of classes and objects, what is a client?
18. Where do class declarations go? Where do the member function definitions go?
19. When one class has a member variable which is an object of a different class they are said to form a ___ relationship?
20. What is the only difference between C++ classes and C++ structs?
Chapter 11 Quiz1. What’s the purpose of a model?
2. What is the basic philosophy of iterative design/development?
3. What’s the difference between waterfall vs. iterative development?
4. What are the 6 steps listed in your book for iterative development.
5. What happens if you lose sight of the vision of your product?
6. What is a use case?
7. What is a domain expert?
8. What is an actor?
9. What are the 6 questions you should ask yourself about the actors when determining use cases, according to your book?
10. What is a domain model?
11. What is a scenario?
12. What are the 9 items, according to your book, should you include when documenting a scenario?
13. What is systems analysis?
14. What is the simplistic technique, according to your book, for determining the classes in your project?
15. What are the three areas of concern for the Static Model of your classes?
16. What is the most important principle when deciding the responsibilities of a class?
17. What are the two types of diagrams shown in the book for determining how classes interact?
Exercise 1 – The random character generatorIn the game “Dungeons & Dragons” by WoTC, each player controls a character. The character has a number of attributes, specifically, they have Strength, Dexterity, Stamina, Intellect, Wisdom, and Charisma – each which can have a score in the range of 1 to 20. These “ability” scores are used to determine the success and/or failure of skills used, as well as how your character performs in combat. We’ll explore more of that later. For this week, I want you to write a program which contains a “Character” class. The character should have attributes representing the 6 ability scores, with accesses for each score. As well, the class should contain two constructors, 1 which takes as input 6 ability scores, and the second which is the default. The default constructor should randomly assign each ability score a value in the range of 1 to 20. To make it easier, I’ve posted the code below to help generate random numbers. Your main function should create two “characters”….one by using the default constructor, and one by passing in values between 1-20…might want to check in your constructor to make sure the input is valid (1-20). After both characters are created, use your accessors to print the attributes of each character to the screen with appropriate labels.
// Required headers#include <stdlib.h>#include <time.h>// Call this ONCE, in your main function to seed the random number generatorsrand( (unsigned)time( NULL ) );// Call this in your default constructor in order to generate a random number from 1 to 20.int randomNum = ( rand() % 20 ) + 1;
Cheers and Good luck!