Professional Documents
Culture Documents
Chapter 3
MORE FLOW OF CONTROL
1. Solutions for and Remarks on Selected Practice Programs and Programming Projects
In order to preserve flexibility of the text, the author has not dealt with classes in this chapter at all. To help
those who really want to do things with classes, some of the Programming Projects will be carried out using
one or several classes.
Here each of two players types in one of strings "Rock", "Scissors", or "Paper". After the second player has
typed in the string, the winner of this game is determined and announced.
Rules:
Rock breaks Scissors
Scissors cuts Paper
Paper covers Rock
If both players give the same answer, then there is no winner.
A nice touch would be to keep and report total wins for each player as play proceeds.
To find the classes, we note first that there are 2 identical players. These players record the character entered,
and keep track of the wins. There is a constructor that sets the total wins to 0. There is a play() member
function that prompts for and gets from the keyboard returns one of the characters 'R', 'P', or 'S' for rock,
paper and scissors. There is an accessor member function for ch and an incrementor member function for
accumulated wins so that a stand alone function int win(ch, ch); can determine who wins and increment the
accumulated wins variable.
(A better solution would make the wins function a friend of class player so that wins can have access
to the each player's private data to determine who wins and update the accumulated wins without the accessor
function ch() and incrementWins() function.)
class player
{
public function members
constructors()
1
Copyright © 2018 Pearson Education, Inc.
Note that once the class is defined and the auxiliary function written, the code “almost writes itself.”
class Player
{
public:
Player();
void play(); //prompts for and gets this player's move
char Ch(); //accessor
int AccumulatedWins(); //accessor
void IncrWins(); //increments win count
private:
char ch; //character typed in
int totalWins; //total of wins
};
2
Copyright © 2018 Pearson Education, Inc.
Savitch Instructor’s Resource Guide
Problem Solving w/ C++, 10e Chapter 3
char Player::Ch()
{
return ch;
}
int Player::AccumulatedWins()
{
return totalWins;
}
void Player::IncrWins()
{
totalWins++;
}
3
Copyright © 2018 Pearson Education, Inc.
Another random document with
no related content on Scribd:
occasionally cut through the rocky soil, and that marks of chariot wheels
were still very evident in many parts of its stony surface.
These approaches to the town, for there are several of them, as will be
seen by the plan, have the appearance of ruined and deserted streets; the
tombs ranged on each side of them supplying the places of houses. The
solemnity, we can scarcely say the gloom, of this effect is, however,
enlivened by the variety of style which characterises the architecture, as
well as by the difference in the plans and sizes of the tombs, and in the
degrees of labour and finish bestowed upon them. The earlier tombs may
be distinguished by their simplicity and good taste, the later by a more
ornamented and a more vitiated style. A similar difference of style may
be observed in the busts and statues, which are scattered about among
the tombs; some of which have the Greek and some the Roman cast of
countenance and costume, portrayed in the several manners peculiar to
each nation, according to the age of the performance.
We were at first induced to stop at every object of importance which
presented itself in our passage through these regions of the dead; but we
soon found that such delays, however agreeable, would make it night
before we reached the city itself if we continued to indulge in them as
our inclination prompted; and we bade our conductor (the chaous from
Bengazi) lead on to that part of it which he himself considered to be most
worthy of particular attention. The taste of the African displayed itself on
this occasion precisely in the manner which we had expected it would
do; and after passing for some little distance along the edge of a ravine
where we perceived the remains of an aqueduct, he descended by a
gentle slope into a level spot of ground, overspread with remains of
building, till we found ourselves at the foot of a perpendicular cliff and
heard the grateful sound of running water. Nothing further was necessary
to rouse the drooping energies of our horses, fatigued with the day’s
journey, and parched with thirst from the heat of the weather; they
sprang forward instinctively, without the stimulus of whip or spur, and
plunging up to their knees in the cool clear stream drank deep of the
fountain of Cyrene.
We are by no means indifferent to the beauties of antiquity,—nay we
often imagine ourselves to be among their most ardent admirers; but we
confess, to our shame, that, on this occasion, we followed the example of
the poor beasts who carried us, and, springing from our saddles, took a
copious draught of the fountain before we turned to pay our homage to
the shrine from which it flowed[21].
FOOTNOTES:
I is not often that an Arab takes an interest in his part when he finds
himself called upon to support the character of a Cicerone; but Chaous
Rabdi had no sooner quenched his own thirst, and allowed his tired horse
to drink as much as he chose, than he was eager to point out to us such of
the wonders as were congenial with his taste for antiquities. He entered
upon his office by desiring us particularly to remark, that this water was
not stagnant like that of the wells which we had seen in other parts of the
country; but that it actually ran, exactly like a river, and afforded a
copious and a constant supply, even in the driest seasons! The exultation
with which our sturdy chaous pronounced the latter part of his harangue
was fully equal to that which the most ardent of antiquaries might
display in pointing out a valuable coin or gem in his collection, which he
considered to be the only one of the kind ever found; and we were no
doubt considered by our worthy conductor as little less than Goths or
Vandals, when, after having given a short assent to the truth of this
remark, we turned towards the mountain from which the water issued,
and entering an excavated chamber which presented itself, began to
examine its connexion with the stream.
We found that a channel had been cut from this apartment far into the
bowels of the rock, (at the height of about five feet from the level of the
chamber,) along which the water flowed rapidly from the interior, and
precipitated itself in a little cascade into a basin, formed to receive it, on
a level with the floor of the apartment: from hence it passed out into the
open space in front of the mountain. The channel forms a passage of
about four feet in height, and is about three feet in breadth; the sides and
roof are flat, but the bed of the stream, which occupies the whole width
of the passage, is worn into irregular forms by the strong and constant
action of the water.
We inquired of the Chaous how far the channel continued to wind into
the heart of the rock, and what it eventually led to; but he could only
inform us that its length had never been ascertained, and that it was
known to be the haunt of demons and fairies, as the Arabs of the place
(he said) could testify! It would have been useless to assert our disbelief
of this statement, that is, of the latter part of it; and having satisfied
ourselves by examining this mysterious passage, as far as the day-light
extended, and ascertaining that it continued still farther into the
mountain, we determined to take an early opportunity of bringing lights
and exploring it to the end, and proceeded to examine the other parts of
the excavation. On one side of the cascade are two excavated chambers,
or rather one chamber divided into two compartments; and in the farther
division is a second basin, sunk below the level of the chamber, which
appears to have originally communicated with the stream by means of a
small aperture in the rock just above it; but no water at present finds its
way through this opening, and the basin would be dry were it not for the
rain which washes into it from without during the winter season. It is
probable that this reservoir was originally devoted to the service of the
priests who had the charge of the sacred stream, in the performance of
their religious ceremonies. Nearly opposite to it is what appears to have
been the principal entrance; and we found here a tablet, broken in two
pieces, which seems to have fallen from over the doorway, and near it
the fragment of a fluted, engaged column. On the tablet is sculptured
three female figures, joining hands as if performing a sacred dance: the
mode of executing the draperies in this bas-relief would seem to point it
out as belonging to a very early period; and the difference of style
between it and another bas-relief which we found near it, representing a
female figure crowning a term, will be obvious on a reference to the
plates of the two performances given. The last-mentioned tablet is of
white marble, in excellent style, and finished with all the delicacy and
taste of the most refined periods: the upper part of it appeared at first
sight to be naked, but on a more attentive inspection it was found to be
covered with what is evidently intended for a light, transparent, drapery,
the few folds of which are very slightly, though very clearly defined, and
result with great propriety as well as simplicity from the easy and
graceful action of the figure. As the tablet has lain for ages with its face
towards the ground, the polish still remains very conspicuously upon its
surface; and contributes to give an additional air of finish to this tasteful
and interesting performance.
The group we first mentioned is executed in sandstone; and it will be
seen that the style of it, although characterised by archaism, is by no
means deficient either in sentiment or taste, or distinguished by an
ignorance of the rules of art. The faces in both of these tablets have been
mutilated, and other parts of the compositions, as will be seen by the
plates, are wanting.
In front of the fountain two porticoes appear to have been erected, if
we judge from the channels which are cut in the surface of the rock, into
which the pediments seem to have been inserted; and on a part of the
cliff, at right angles with the face of the rock, is an inscription in Doric
Greek recording the name of a priest who built one of the porticoes in
question[1].
It is probable that the separation of a part of the cliff from the rest, in
consequence of the foundation having given way, was the cause of the
destruction of the portico of Dionysius, (the name which is mentioned in
the inscription;) no other indications of which now remain except the
marks we have alluded to in the surface of the rock. The front of the
fountain is however much encumbered with soil, washed down by the
winter rains from above; and parts of the portico may yet be found
beneath it should this place be excavated at any future period: the
chambers within are also much encumbered with the same material,
washed in through the entrance where the tablet was discovered, and it is
by no means improbable that interesting remains might be found
underneath the soil which is collected there.
There is a good deal of building in front of the mountain (without the
limits which we may suppose to have been occupied by the portico of
Dionysius,) of which it seems difficult to establish the nature; if it be not
in some way connected with the reception of the water, and its
distribution over the town of Cyrene. It appears to us that the stream was
originally confined, and raised by lateral compression to a height
sufficient to allow of its being conducted into different parts of the town,
the level of which is considerably above that of the fountain itself; but in
what precise manner this object was accomplished we will not here
venture to suggest. The remains of an aqueduct are still visible on the
brow of the hill, from which the cliff descends perpendicularly to the
fountain, leading from thence to the brink of a ravine on the opposite
side, down which also flows another stream of excellent water. From the
traces of building which we perceived about this ravine we should
imagine that the aqueduct had been formerly thrown across it, and the
water distributed over the cultivated grounds which lie without the walls
of the city; at present the stream which flows down it, as well as that of
the fountain already described, finds its way over the country below into
the sea, and is no otherwise serviceable than as it affords an occasional
draught to the Bedouins who frequent the neighbourhood during the
summer, and to the cattle who drink with their masters. The excavated
chambers of the fountain of Apollo[2] are occupied at this season by
flocks of sheep and goats, and the whole of the level space in front of the
mountain is thickly covered at such times with these animals, as well as
with numerous herds of cattle, attracted thither by the water which now
strays over its surface. When we first arrived at Cyrene these intruders
had not made their appearance; and we rambled about, to our great
comfort and satisfaction, without meeting a single living creature besides
those of our own party in the day time, and a few jackalls and hyænas in
the morning and evening, which always ran off on our approach.
After satisfying our thirst, and, in some degree, our curiosity, at the
fountain, we descended a few feet to some remains which we perceived
on a level piece of ground below it; and found that they were those of a
peripteral temple which, from the fragment of an inscription that we
discovered among its ruins, mentioning the name of the Goddess,
appears to have been dedicated to Diana.
Little more than the ground-plan of this temple is now remaining, and
most of the columns are buried beneath the soil; we were able, however,
to ascertain that the portico was hexastyle, and the columns about four
feet and a half in diameter: those on the south side are so completely
buried that no traces of them whatever are visible; but from those which
are still in their places on the opposite side we were led to suppose that
the number of columns was no more than ten, instead of eleven, which is
the usual proportion in peripteral temples according to the rules laid
down by Vitruvius[3]. As the number of lateral intercolumniations would
not, with this disposition, be double the number of those in the front, the
whole length of the temple in question could not be equal to twice its
breadth, which we accordingly find to be the case: and it is probable,
therefore, that the ædes, or body of the temple, was built before the other
parts of it, and that the columns and porticoes were added at a
subsequent period, and the number of pillars regulated by the dimensions
of what was already constructed. At the same time the width of the
intercolumniations does not appear to have been greater than seven feet,
which is scarcely more (as compared with the size of the shaft) than the
shortest space allowed between columns in Greek and Roman
architecture[4]. There are no columns, at either end, between the antæ in
this temple; and the walls of the ædes must have been continued from the
angle till they reached the jambs of the doorways. If the statue of the
deity looked towards the west (as recommended by Vitruvius, chap. v.)[5]
it must have been placed in the pronaos, and not in the cella, to have
been seen through the doorway from without; for the wall which divides
the cella from the pronaos continued too far across the interior to have
allowed of any door in the centre of it, opening from one of these to the
other, (as will appear by the plan;) and it would be absurd to look for a
communication between them in any other part of the wall. Under this
disposition, had the statue been in the cella, and its face turned towards
the west, it must have looked against the wall in question; and could not
have been seen at all from the western front of the temple[6]. From the
portions of Doric entablature which we perceived among the ruins of this
temple, we may conjecture that it was of that order; but we could no
where discover any parts of the capitals belonging to the columns, and
the bases, if ever there were any, are buried under the soil which has
accumulated about the building. It will be seen by the plate (page 430)
that there is a building attached to this temple on the northward which
has no connection with its original plan; and there are other remains of
building beyond these, and to the westward of them, which will require
excavation to determine their plans. We have already mentioned the
fragment from which we have ventured to conjecture that the temple was
dedicated to Diana; and we may add that a mutilated female figure (of
which we have given a drawing, page 427) was also found close to its
northern wall. The statue, it will be seen, is in a sitting position; and a
part of the chair only was visible when we first discovered it among the
heavy fragments of building with which it was encumbered, as well as
with the soil which had accumulated about it. We succeeded, however,
after some trouble in clearing it, and were rather disappointed at finding
so little of it remaining. The girdle which encircles the waist of this
figure has been executed with great care and precision; it is represented
as closely tied, and the ends of it, which hang down in front, are finished
with little tassels strongly relieved from the surface of the drapery; this
object, in fact, seems to have been one of primary importance with the
sculptor, and may have been intended (if we suppose it to have been the
statue of Diana) to point out symbolically the peculiar characteristic of
the goddess, her attachment to (or rather her profession of) perpetual
celibacy[7].
It was between the remains of the temple of Diana and the fountain
that we discovered the beautiful bas-relief of white marble which we
have already mentioned above; and near it we found the torso of a male
figure the size of life (also of white marble) executed in the best style of
Grecian sculpture.
A little beyond this temple the level tract of ground stretching out
from the base of the cliff from which the fountain issues is terminated by
a strongly-built wall, the top of which is even with the surface; it has
been built for the purpose of keeping up the soil, which would otherwise,
from the abrupt descent of the ground, be washed down by the winter
rains and the buildings upon it exposed to be undermined. This wall,
which is a very conspicuous object from below, must have formed in its
perfect state an admirable defence, as it would have effectually precluded
the possibility of any approach to the place from the country beneath.
Since the waters of the fountain have been left to their natural course the
stream pours itself over the top of the wall in a pretty, romantic-looking
cascade; the effect of which is heightened by the trees growing up
against the barrier, amongst whose branches the water dashes in its
passage to the plains below. A few paces beyond the first wall the ground
again descends abruptly and is kept up by a similar structure; after which
it continues to do so more rapidly, each descent being quickly succeeded
by another, till they finish altogether at the foot of the mountain.
The position of Cyrene is, in fact, on the edge of a range of hills of
about eight hundred feet in height, descending in galleries, one below
another, till they are terminated by the level ground which forms the
summit of a second range beneath it. At the foot of the upper range, on
which the city was built, is a fine sweep of table-land most beautifully
varied with wood, among which are scattered tracts of barley and corn,
and meadows which are covered for a great part of the year with verdure.
Ravines, whose sides are thickly covered with trees, intersect the country
in various directions, and form the channels of the mountain-streams in
their passage from the upper range to the sea. The varied tract of table-
land of which we are speaking extends itself east and west as far as the
eye can reach; and to the northward (after stretching about five miles in
that direction) it descends abruptly to the sea. The lower chain, which
runs all along the coast of the Cyrenaica, is here, as it is at Ptolemeta and
other places, thickly covered with wood, and intersected, like the upper
range, with wild and romantic ravines; which assume grander features as
they approach the sea. The height of the lower chain may be estimated at
a thousand feet, and Cyrene, as situated on the summit of the upper one,
is elevated about eighteen hundred feet from the level of the sea, of
which it commands an extensive view over the top of the range below
it[8]. For a day or two after our first arrival at Cyrene a thick haze had
settled over the coast, and we were not aware that the sea was seen so
plainly from the town as we afterwards found it to have been. When the
mist cleared away the view was truly magnificent; and may be said to be
one of those which remain impressed upon the mind, undiminished in
interest by a comparison with others, and as strongly depicted there after
a lapse of many years as if it were still before the eyes. We shall never
forget the first effect of this scene (on approaching the edge of the height
on which Cyrene is situated) when the fine sweep of land which lies
stretched at the foot of the range burst suddenly upon us in all its varied
forms and tints; and imagination painted the depth of the descent from
the summit of the distant hills beneath us to the coast, terminated by the
long uninterrupted line of blue, which was distinguished rising high in
the misty horizon. If we knew in what the powers of description
consisted we should be tempted to employ them on this occasion; and
would endeavour to convey to the minds of our readers the same
impressions of the beautiful position of Cyrene which the view of it
suggested to ourselves. But one glance of the eye is, we fear, worth
more, in calling up the feelings which are produced by fine scenery, than
all that description is capable of effecting; and the impressions which
time will never efface from our own minds would never (it is probable)
be stamped, by words of ours, on the minds of those in whom we could
wish to excite them. Under this conviction we will turn from the view
before us, and proceed to describe a very remarkable peculiarity in the
northern face of the heights of Cyrene. We have already stated that the
side of the mountain descends abruptly, in this direction, to the plain
below; not by a single, unbroken descent, but in ledges, or galleries, one
above another, which terminate only in the plain itself. The Cyreneans
have judiciously taken advantage of this formation, and shaped the
ridges alluded to into practicable roads leading along the side of the
mountain, which have originally communicated in some instances one
with another by means of narrow flights of steps cut in the rock. The
roads are to this day very plainly indented with the marks of chariot
wheels deeply sunk in their smooth stony surface; and appear to have
been the favourite drives of the inhabitants who enjoyed from them the
delightful view which we have despaired of being able to place before
our readers. The rock, in most instances, rises perpendicularly from one
side of these aërial galleries, and is excavated into innumerable tombs,
which have been formed with great labour and taste, and the greater
number of them have been adorned with architectural façades built
against the smooth side of the rock itself, contributing materially to
increase the interest, and to add to the beauty of the drives. When the
rock would serve for the porticoes in front of the tombs, without any
addition of building, it was left in the forms required; and if only a part
of it would serve, the remainder was added by the architect. This mode
of proceeding added greatly to the strength of the work, and was
probably attended, at the same time, with a saving of labour. The outer
sides of the roads, where they descended from one range to another, were
ornamented with sarcophagi and monumental tombs, and the whole
sloping space between the galleries was completely filled up with similar
structures. These, as well as the excavated tombs, exhibit very superior
taste and execution; and the clusters of dark green furze and slender
shrubs with which they are now partly overgrown, give an additional
effect, by their contrast of forms and colour, to the multitude of white
buildings which spring up from the midst of them. We have endeavoured
in the drawing here annexed, to give some idea of this remarkable scene;
but although we have copied it with fidelity, and with all the care which
our time allowed, the effect of our view falls very far short of that which
is produced by the scene itself[9].
On leaving the fountain and the temple of Diana we descended the
side of the hill and took our course along the galleries we have
mentioned, passing with some difficulty from one to another, through the
thick furze with which the ground is overspread, and entering the most
conspicuous of the excavated tombs which we passed in our route along
the roads.
They usually consisted of a single chamber; at the end of which,
opposite the doorway, was an elegant, highly finished façade, almost
always of the Doric order, cut in the smooth surface of the rock itself
with great regularity and beauty of execution. It generally represented a
portico, and the number of columns by which it was supposed to be
supported varied according to the length of the tomb. The spaces
between the columns themselves also varied; the porticoes being
sometimes monotriglyph, and sometimes ditriglyph, according to the
fancy of the architect. Between the columns were the cellæ (if we may
call them so) for the reception of the ashes or the bodies of the deceased,
cut far into the rock, at right angles with the façade; and the height of
these was necessarily regulated by that of the columns from the level of
the chamber[10]. As the spaces between the columns were wider, or
otherwise, the width of the cellæ varied accordingly, there never being
more than one of these recesses between any two of the columns. The
cellæ had often separate façades on a smaller scale than the principal
one, but always of the same order; and they were occasionally made to
represent doorways: the entrance to them appears to have been originally
closed with a tablet of stone on which there was probably some
inscription recording the names of the persons within. In some instances
part of such a tablet was left standing, but we never found one entire in
any of the tombs, and very rarely saw fragments of them at all. As most
of the chambers are, however, much encumbered with soil washed in by
the rains through the doorway of the tomb, it is probable that some of
these might be found entire on excavating either the chambers
themselves, or the ground immediately about the entrance to them[11].
The cellæ were sometimes sunk to a considerable depth below the levels
of the chambers, and contained ranges of bodies or cineral urns placed
one above another, each division being separated from that above and
beneath it by a slab of stone, resting on a projecting moulding which was
raised on two sides of the cella. There are also divisions, in many
instances, in the length of the cellæ, some of them containing three and
four places for bodies on the same level, but these are always ranged (to
use a naval phrase) head and stern of each other; and we never saw an
instance in which any two of them were parallel. In fact, the width of the
cella, which, we have already stated, was regulated by the space between
the columns, would have rendered such an arrangement impossible,
since it was of the same breadth in all parts, whatever might be its extent
in length and depth. For a more complete idea of these elegant mansions
of the dead we refer our readers to the plates containing the ground-plans
and elevations of such of them as we had time to secure on paper. It will
be seen that the proportions of the several members of the entablature
varied considerably in the few instances given; and indeed, we may say
that there are scarcely two façades where the measurements exactly
correspond[12].