Skip to content

Commit

Permalink
Ch 11 (11.1-11.11)
Browse files Browse the repository at this point in the history
  • Loading branch information
sravanibattula2 committed Feb 5, 2021
1 parent edb0afc commit 7b21f32
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 26 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified __pycache__/pavement.cpython-38.pyc
Binary file not shown.
Binary file modified _sources/.DS_Store
Binary file not shown.
10 changes: 6 additions & 4 deletions _sources/Chapter11/a_more_complicated_example.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A more complicated example
A more complicated example
--------------------------

Although the process of transforming functions into member functions is
Expand Down Expand Up @@ -82,7 +82,7 @@ after the current-time, then...”
:answer_d: "hour" and "minute" refer to the hour and minute of the implicit Time object.
:correct: b,d
:feedback_a: Incorrect! There are actually two Time parameters, one of them is implicit.
:feedback_b: Correct!
:feedback_b: Correct! There are two Time objects - the implicit one and time2.
:feedback_c: Incorrect! The function is invoked on the implicit Time object.
:feedback_d: Correct!

Expand All @@ -95,7 +95,7 @@ after the current-time, then...”
:answer_d: Four
:correct: c
:feedback_a: Incorrect! There is One implicit structure.
:feedback_b: Incorrect!
:feedback_b: Incorrect! Keep in mind there are 4 structures and 1 is implicit.
:feedback_c: Correct! There is One implicit structure, and three structures that need to be accessed with dot notation.
:feedback_d: Incorrect! We shouldn't need to use dot notation for all of them!

Expand Down Expand Up @@ -130,4 +130,6 @@ after the current-time, then...”
=====
}; #paired
=====
Dog dog = *this; #distractor
Dog dog = *this; #distractor
=====
bool Dog::is_older(const Dog& dog2) { #distractor
7 changes: 3 additions & 4 deletions _sources/Chapter11/another_example.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Another example
Another example
---------------

Let’s convert ``increment`` to a member function. Again, we are going to
Expand Down Expand Up @@ -92,7 +92,7 @@ The output of this program is ``9:22:50``.

Suppose we have previously declared ``Time currentTime = {9, 14, 30.0}``. What should be printed by ``time.print()`` after calling ``time.increment(645.0)``? Type your response in the form **hh:mm:ss**.

- :(9:25:15): Correct!
- :(9:25:15)|(09:25:15): Correct!
:.*: Incorrect! Try plugging the given input into the active code above!

.. fillintheblank:: another_example_2
Expand Down Expand Up @@ -152,7 +152,7 @@ The output of this program is ``9:22:50``.
return false;
}
=====
if (cat.speed * 2 > age * weight) { #paired
if (cat.speed * 2 > age * weight) { #distractor
return true;
}
return false;
Expand All @@ -163,4 +163,3 @@ The output of this program is ``9:22:50``.
}
return false;
}
4 changes: 3 additions & 1 deletion _sources/Chapter11/constructors.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Constructors
Constructors
------------

Another function we wrote in Chapter `[time] <#time>`__ was
Expand Down Expand Up @@ -70,11 +70,13 @@ result is assigned to the variable ``time``.
:answer_b: They have the same name as the class.
:answer_c: They return an instance of an object.
:answer_d: We refer to the objects they initialize implicitly, or using keyword this.
:answer_e: They have the same name as the class, no return type and unchanged parameters.
:correct: c
:feedback_a: Incorrect! This statement is true!
:feedback_b: Incorrect! This statement is true!
:feedback_c: Correct! Constructors do not have a return type.
:feedback_d: Incorrect! This statment is true!
:feedback_e: Incorrect! This statement is true!

Which statment is **false** about constructors?

Expand Down
4 changes: 2 additions & 2 deletions _sources/Chapter11/one_last_example.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
One last example
One last example
----------------

The final example we’ll look at is ``addTime``:
Expand Down Expand Up @@ -115,7 +115,7 @@ object.

.. fillintheblank:: one_last_example_2

We have previously initialized t1 and t1 using constructors ``Time t1 (8, 30, 45.0)``
We have previously initialized t1 and t2 using constructors ``Time t1 (8, 30, 45.0)``
and ``Time t2 (1, 50, 13.0)``. What should be returned by ``t1.add(t2)``?

- :(10:20:58): Correct!
Expand Down
18 changes: 6 additions & 12 deletions _sources/Chapter11/print.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
``print``
``print``
---------

In Chapter `[time] <#time>`__ we defined a structure named ``Time`` and
Expand Down Expand Up @@ -144,10 +144,10 @@ will complain.

.. mchoice:: print_2
:multiple_answers:
:answer_a: change the name of the function to Dog::bark
:answer_b: remove the Dog parameter
:answer_c: operate on the current Dog object by using *this
:answer_d: declare the function inside of the Dog structure definition
:answer_a: Change the name of the function to Dog::bark
:answer_b: Remove the Dog parameter
:answer_c: Operate on the current Dog object by using *this
:answer_d: Declare the function inside of the Dog structure definition
:correct: b,c,d
:feedback_a: Incorrect! You don't need to rename the function unless you define it outside of the structure definition.
:feedback_b: Correct! We no longer need to pass a Dog as an argument, since we are going to be invoking the function on a Dog object.
Expand All @@ -160,7 +160,7 @@ will complain.
:numbered: left
:adaptive:

Create the ``Dog`` object with member functions ``bark`` and ``is_teacup_dog``. Write the functions
Create the ``Dog`` object with member functions ``bark`` and ``is_teacup_dog`` (if the weight of the dog is less than 4 pounds) Write the functions
in the same order they appear inside the structure.
-----
struct Dog {
Expand Down Expand Up @@ -193,9 +193,3 @@ will complain.
}
return false;
}
=====
if (dog.weight < 4) { #paired
return true;
}
return false;
}
Binary file modified build/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion build_info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
unknown-0-0
unknown-0-0
2 changes: 1 addition & 1 deletion pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#new 7/2019 changes
# Change to False when running localhost
dynamic_pages = True
dynamic_pages = False

if dynamic_pages:
dest = './published'
Expand Down
2 changes: 1 addition & 1 deletion sphinx_settings.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"SPHINX_SOURCE_PATH": "_sources", "SPHINX_OUT_PATH": "build\\thinkcpp"}
{"SPHINX_SOURCE_PATH": "_sources", "SPHINX_OUT_PATH": "build/thinkcpp"}

0 comments on commit 7b21f32

Please sign in to comment.