From b313ad8364aa6526709792a25bae2316b9a46f8e Mon Sep 17 00:00:00 2001 From: Frank Filthaut Date: Thu, 14 Nov 2019 22:12:20 +0100 Subject: [PATCH] add inputs for ex4.1, ex4.3, ex5.2, ex5.3 --- ex4.1/Button.hh | 17 ++++++++++ ex4.1/Cable.hh | 13 ++++++++ ex4.1/Chassis.hh | 17 ++++++++++ ex4.1/Dialer.hh | 20 ++++++++++++ ex4.1/Earpiece.hh | 16 +++++++++ ex4.1/Handset.hh | 25 ++++++++++++++ ex4.1/Housing.hh | 22 +++++++++++++ ex4.1/Mouthpiece.hh | 16 +++++++++ ex4.1/Shell.hh | 17 ++++++++++ ex4.1/Telephone.hh | 25 ++++++++++++++ ex4.3/String.hh | 28 ++++++++++++++++ ex5.2/data1.txt | 9 +++++ ex5.3/example.txt | 80 +++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 305 insertions(+) create mode 100644 ex4.1/Button.hh create mode 100644 ex4.1/Cable.hh create mode 100644 ex4.1/Chassis.hh create mode 100644 ex4.1/Dialer.hh create mode 100644 ex4.1/Earpiece.hh create mode 100644 ex4.1/Handset.hh create mode 100644 ex4.1/Housing.hh create mode 100644 ex4.1/Mouthpiece.hh create mode 100644 ex4.1/Shell.hh create mode 100644 ex4.1/Telephone.hh create mode 100644 ex4.3/String.hh create mode 100644 ex5.2/data1.txt create mode 100644 ex5.3/example.txt diff --git a/ex4.1/Button.hh b/ex4.1/Button.hh new file mode 100644 index 0000000..31cb912 --- /dev/null +++ b/ex4.1/Button.hh @@ -0,0 +1,17 @@ +#ifndef BUTTON_HH +#define BUTTON_HH + +#include + +class Button { +public: + + Button() { std::cout << "Button Constructor " << this << std::endl ; } + Button(const Button&) { std::cout << "Button Copy Constructor " << this << std::endl ; } + ~Button() { std::cout << "Button Destructor " << this << std::endl ; } + +private: + +} ; + +#endif diff --git a/ex4.1/Cable.hh b/ex4.1/Cable.hh new file mode 100644 index 0000000..78a7132 --- /dev/null +++ b/ex4.1/Cable.hh @@ -0,0 +1,13 @@ + +#include + +class Cable { +public: + + Cable() { std::cout << "Cable Constructor " << this << std::endl ; } + Cable(const Cable&) { std::cout << "Cable Copy Constructor " << this << std::endl ; } + ~Cable() { std::cout << "Cable Destructor " << this << std::endl ; } + +private: + +} ; diff --git a/ex4.1/Chassis.hh b/ex4.1/Chassis.hh new file mode 100644 index 0000000..60be87e --- /dev/null +++ b/ex4.1/Chassis.hh @@ -0,0 +1,17 @@ +#ifndef CHASSIS_HH +#define CHASSIS_HH + +#include + +class Chassis { +public: + + Chassis() { std::cout << "Chassis Constructor " << this << std::endl ; } + Chassis(const Chassis&) { std::cout << "Chassis Copy Constructor " << this << std::endl ; } + ~Chassis() { std::cout << "Chassis Destructor " << this << std::endl ; } + +private: + +} ; + +#endif diff --git a/ex4.1/Dialer.hh b/ex4.1/Dialer.hh new file mode 100644 index 0000000..996545b --- /dev/null +++ b/ex4.1/Dialer.hh @@ -0,0 +1,20 @@ +#include +#ifndef DIALER_HH +#define DIALER_HH + +#include "Button.hh" + +class Dialer { +public: + + Dialer() { std::cout << "Dialer Constructor " << this << std::endl ; } + Dialer(const Dialer&) { std::cout << "Dialer Copy Constructor " << this << std::endl ; } + ~Dialer() { std::cout << "Dialer Destructor " << this << std::endl ; } + +private: + + Button buttons[12] ; + +} ; + +#endif diff --git a/ex4.1/Earpiece.hh b/ex4.1/Earpiece.hh new file mode 100644 index 0000000..ef843c4 --- /dev/null +++ b/ex4.1/Earpiece.hh @@ -0,0 +1,16 @@ +#include +#ifndef EARPIECE_HH +#define EARPIECE_HH + +class Earpiece { +public: + + Earpiece() { std::cout << "Earpiece Constructor " << this << std::endl ; } + Earpiece(const Earpiece&) { std::cout << "Earpiece Copy Constructor " << this << std::endl ; } + ~Earpiece() { std::cout << "Earpiece Destructor " << this << std::endl ; } + +private: + +} ; + +#endif diff --git a/ex4.1/Handset.hh b/ex4.1/Handset.hh new file mode 100644 index 0000000..c0cd9ea --- /dev/null +++ b/ex4.1/Handset.hh @@ -0,0 +1,25 @@ +#include +#ifndef HANDSET_HH +#define HANDSET_HH + +#include "Mouthpiece.hh" +#include "Earpiece.hh" +#include "Cable.hh" + +class Handset { +public: + + Handset() { std::cout << "Handset Constructor " << this << std::endl ; } + Handset(const Handset&) { std::cout << "Handset Copy Constructor " << this << std::endl ; } + ~Handset() { std::cout << "Handset Destructor " << this << std::endl ; } + +private: + + Mouthpiece mouthpiece ; + Earpiece earpiece ; + Cable cable ; + + +} ; + +#endif diff --git a/ex4.1/Housing.hh b/ex4.1/Housing.hh new file mode 100644 index 0000000..4d1334b --- /dev/null +++ b/ex4.1/Housing.hh @@ -0,0 +1,22 @@ +#include +#ifndef HOUSING_HH +#define HOUSING_HH + +#include "Chassis.hh" +#include "Shell.hh" + +class Housing { +public: + + Housing() { std::cout << "Housing Constructor " << this << std::endl ; } + Housing(const Housing&) { std::cout << "Housing Copy Constructor " << this << std::endl ; } + ~Housing() { std::cout << "Housing Destructor " << this << std::endl ; } + +private: + + Chassis chassis ; + Shell shell ; + +} ; + +#endif diff --git a/ex4.1/Mouthpiece.hh b/ex4.1/Mouthpiece.hh new file mode 100644 index 0000000..a882627 --- /dev/null +++ b/ex4.1/Mouthpiece.hh @@ -0,0 +1,16 @@ +#include +#ifndef MOUTHPIECE_HH +#define MOUTHPIECE_HH + +class Mouthpiece { +public: + + Mouthpiece() { std::cout << "Mouthpiece Constructor " << this << std::endl ; } + Mouthpiece(const Mouthpiece&) { std::cout << "Mouthpiece Copy Constructor " << this << std::endl ; } + ~Mouthpiece() { std::cout << "Mouthpiece Destructor " << this << std::endl ; } + +private: + +} ; + +#endif diff --git a/ex4.1/Shell.hh b/ex4.1/Shell.hh new file mode 100644 index 0000000..e14e653 --- /dev/null +++ b/ex4.1/Shell.hh @@ -0,0 +1,17 @@ +#ifndef SHELL_HH +#define SHELL_HH + +#include + +class Shell { +public: + + Shell() { std::cout << "Shell Constructor " << this << std::endl ; } + Shell(const Shell&) { std::cout << "Shell Copy Constructor " << this << std::endl ; } + ~Shell() { std::cout << "Shell Destructor " << this << std::endl ; } + +private: + +} ; + +#endif diff --git a/ex4.1/Telephone.hh b/ex4.1/Telephone.hh new file mode 100644 index 0000000..33a6db0 --- /dev/null +++ b/ex4.1/Telephone.hh @@ -0,0 +1,25 @@ +#ifndef TELEPHONE_HH +#define TELEPHONE_HH + +#include "Cable.hh" +#include "Housing.hh" +#include "Dialer.hh" +#include "Handset.hh" + +class Telephone { +public: + + Telephone() { std::cout << "Telephone Constructor " << this << std::endl ; } + Telephone(const Telephone&) { std::cout << "Telephone Copy Constructor " << this << std::endl ; } + ~Telephone() { std::cout << "Telephone Destructor " << this << std::endl ; } + +private: + + Cable cable ; + Housing housing ; + Dialer dialer ; + Handset handset ; + +} ; + +#endif diff --git a/ex4.3/String.hh b/ex4.3/String.hh new file mode 100644 index 0000000..7bca087 --- /dev/null +++ b/ex4.3/String.hh @@ -0,0 +1,28 @@ +#ifndef STRING_HH +#define STRING_HH + +class String { +public: + + String(const char* str="") : _s(0) { insert(str) ; } + String(const String& a) : _s(0) { insert(a._s) ; } + ~String() { delete[] _s ; } + + int length() const { return _len ; } + const char* data() const { return _s ; } + +private: + + char* _s ; + int _len ; + + void insert(const char* str) { // private helper function + _len = strlen(str) ; + if (_s) delete[] _s ; + _s = new char[_len+1] ; + strcpy(_s,str) ; + } + +} ; + +#endif diff --git a/ex5.2/data1.txt b/ex5.2/data1.txt new file mode 100644 index 0000000..7da3328 --- /dev/null +++ b/ex5.2/data1.txt @@ -0,0 +1,9 @@ +586 +2746 +348946 +-472 +72734 +-283 +263 +0 +4957 diff --git a/ex5.3/example.txt b/ex5.3/example.txt new file mode 100644 index 0000000..4b4673a --- /dev/null +++ b/ex5.3/example.txt @@ -0,0 +1,80 @@ +The upscale food court in the Time Warner Center can be derided for +many reasons, but a lack of clear marking is not among them. From the +moment you walk into the center, no matter which entrance you use, you +encounter signs pointing the way to the preciously termed "restaurant +and bar collection" a few stories up. + +But during a lunchtime visit to one of the restaurants last fall I +encountered a well-dressed gentleman, perhaps in his early 60's, who +paced before the elevators on the ground level. In a confused voice he +asked me the location of the restaurant Per Se, where he had a coveted +reservation. + +"The fourth floor," I said. He stared at me quizzically. I gestured to +one of those signs. I repeated my answer. Finally he climbed aboard an +elevator with me. But I could tell that he still had doubts. He seemed +unable to believe that one of Manhattan's most ambitious new +restaurants was high above the street in a corner of a shopping mall. + +In fact four of Manhattan's most ambitious new restaurants are in this +"vertical retail environment," as its promoters prefer to call +it. Their eagerness to euphemize underscores the boldness of their +experiment: asking New York diners to consider elevators, escalators +and bright indoor lighting appropriate visual preludes to extremely +expensive dinners. + +Nearly a year since the center opened it is still too soon to tell +whether that experiment will literally pay off. But those restaurants +- Per Se, Masa and V Steakhouse on the fourth floor and Café Gray on +the third - have been operating long enough for answers to other +questions. How crucially is fine dining affected by an unusual +physical context? What is it like to cross yards of gleaming marble +and brave the glaring seductions of Samsung and Sephora on the way to +and from an appointment with foie gras? + +It is usually disconcerting. It is sometimes disorienting. Alongside +the restaurants on the fourth floor is a bar, the Stone Rose, whose +music echoes up and down the hall, trapped under the same roof. I left +Masa one night and felt my post-toro tranquility shatter under the +oppressive beat and incongruous lyrics of "Hungry Like the Wolf." I +was irritated like the coyote. + +But an hour and then a day later I did not remember Masa less fondly +or long to return less ardently. The layout and gestalt of the Time +Warner Center were annoyances, but they were ignorable. The center +proves that restaurants transcend their trappings, a truth that was +often overlooked as culinary connoisseurs fretted about celebrated +chefs like Thomas Keller and Jean-Georges Vongerichten setting up +kitchens in the kind of structure that often bestrides a highway +access road. + +For New Yorkers the center is a jarring development but also a +positive one. Without it Mr. Keller, the head chef of Per Se, might +not have set up a kitchen here at all. Because the center is a +mixed-use development in which the restaurants lend cachet to the +residences and office space, Mr. Keller could be offered an economic +safety net, a deal that insulated him from financial failure. + +Mr. Vongerichten, the supervising chef of V Steakhouse, benefited from +a similar arrangement, and the aggregate glitter of these two helped +to lure Masayoshi Takayama, the chef at Masa, and Gray Kunz of Café +Gray. The four restaurants that they guide - plus a fifth, under the +stewardship of the chef Charlie Trotter, to come sometime over the +next year - probably wouldn't exist without their atypical commercial +cradle. + +Would they be more appealing at street level, with sidewalks in front +and portals that admitted natural light? In most ways, yes. Their odd +situations yield unsettling effects. After hours in the dimly lighted +fantasy of Per Se, a diner is thrust not into moonbeams and fresh air +but into the harshly illuminated, stale reality of the rest of the +center. A cold slap punctuates a warm hug. + +Or sometimes the rest of the center is thrust upon a diner. One night +I watched a woman and her two teenage daughters, all three dressed in +white Capri pants and brightly colored T-shirts, march straight into +Masa and then into Per Se, just to have a look. Understandably they +treated the exclusive restaurants on the fourth floor the way they had +treated stores on the lower three, as crannies of a mall that invited +exploration. +