diff --git a/src/main/java/io/zipcoder/ParenChecker.java b/src/main/java/io/zipcoder/ParenChecker.java index caee675..90a41cc 100644 --- a/src/main/java/io/zipcoder/ParenChecker.java +++ b/src/main/java/io/zipcoder/ParenChecker.java @@ -1,4 +1,83 @@ package io.zipcoder; +import java.util.Stack; + public class ParenChecker { + private Stack charStack; + + public ParenChecker() { + this.charStack = new Stack(); + } + + public void add(String input) { + for (int i = 0; i < input.length(); i++) { + if (input.charAt(i) != 32) { + charStack.add(input.charAt(i)); + } + } + } + + public String getCharString() { + StringBuilder result = new StringBuilder(); + result.append(charStack); + return result.toString(); + } + + public boolean isOpen() { + boolean result = true; + int openCount = 0; + int quoteCount = 0; + for (int i = 0; i < charStack.size(); i++) { + char input = charStack.get(i).toString().charAt(0); + switch (input) { + case '(': + openCount++; + break; + case ')': + openCount--; + break; + case '{': + openCount++; + break; + case '}': + openCount--; + break; + case '[': + openCount++; + break; + case ']': + openCount--; + break; + case '<': + openCount++; + break; + case '>': + openCount--; + break; + case 34: + if (quoteCount == 1) { + openCount--; + quoteCount--; + break; + } + openCount++; + quoteCount++; + break; + case 39: + if (quoteCount == 1) { + openCount--; + quoteCount--; + break; + } + openCount++; + quoteCount++; + break; + } + } + if (openCount == 0) { + result = false; + } + return result; + } + } diff --git a/src/main/java/io/zipcoder/WC.java b/src/main/java/io/zipcoder/WC.java index babb68c..3d45e54 100644 --- a/src/main/java/io/zipcoder/WC.java +++ b/src/main/java/io/zipcoder/WC.java @@ -2,11 +2,11 @@ import java.io.FileNotFoundException; import java.io.FileReader; -import java.util.Iterator; -import java.util.Scanner; +import java.util.*; public class WC { private Iterator si; + private Map wordsAndCounts = new LinkedHashMap(); public WC(String fileName) { try { @@ -20,4 +20,40 @@ public WC(String fileName) { public WC(Iterator si) { this.si = si; } + + public WC() {} + + public void program(){ + ArrayList words = new ArrayList(); + do{ + words.add(si.next()); + }while(si.hasNext() == true); + fillTreeMap(words); + printInfo(); + } + + private void printInfo() { + for(Map.Entry entry : wordsAndCounts.entrySet()){ + System.out.println(String.format("Word: %-20s | Occurrences: %s", entry.getKey().toString(), entry.getValue().toString())); + } + } + + public void fillTreeMap(ArrayList words){ + Collections.sort(words, Collections.reverseOrder()); + for(Object element : words){ + int occ = getOccurrences(element, words); + wordsAndCounts.put(element.toString(), occ); + } + } + + public int getOccurrences(Object element, ArrayList words){ + int wordCount = 0; + for(Object word : words){ + if(word.equals(element)){ + wordCount++; + } + } + return wordCount; + } + } diff --git a/src/main/resources/documentationDef.txt b/src/main/resources/documentationDef.txt new file mode 100644 index 0000000..e0c299a --- /dev/null +++ b/src/main/resources/documentationDef.txt @@ -0,0 +1,2 @@ +a : the provision of documents in substantiation; also : documentary evidence +b : the use of historical documents : conformity to historical or objective facts : the provision of footnotes, appendices, or addenda referring to or containing documentary evidence \ No newline at end of file diff --git a/src/main/resources/someTextFile.txt b/src/main/resources/someTextFile.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/resources/theBook.txt b/src/main/resources/theBook.txt new file mode 100644 index 0000000..73ee8c8 --- /dev/null +++ b/src/main/resources/theBook.txt @@ -0,0 +1,1053 @@ +The Project Gutenberg EBook of Members of the Family, by Owen Wister + +This eBook is for the use of anyone anywhere at no cost and with +almost no restrictions whatsoever. You may copy it, give it away or +re-use it under the terms of the Project Gutenberg License included +with this eBook or online at www.gutenberg.org/license + + +Title: Members of the Family + +Author: Owen Wister + +Illustrator: H. T. Dunn + +Release Date: March 10, 2018 [EBook #56717] + +Language: English + +Character set encoding: UTF-8 + +*** START OF THIS PROJECT GUTENBERG EBOOK MEMBERS OF THE FAMILY *** + + + + +Produced by Chuck Greif & The Online Distributed +Proofreading Team at http://www.pgdp.net (This file was +produced from images generously made available by The +Internet Archive) + + + + + + + + + + + MEMBERS OF THE FAMILY + + [Illustration] + + THE MACMILLAN COMPANY + NEW YORK · BOSTON · CHICAGO + SAN FRANCISCO + + MACMILLAN & CO., LIMITED + LONDON · BOMBAY · CALCUTTA + MELBOURNE + + THE MACMILLAN CO. OF CANADA, LTD. + TORONTO + + [Illustration: “Pie like mother made,” said Scipio] + + + + + MEMBERS OF THE FAMILY + + BY + OWEN WISTER + + + WITH ILLUSTRATIONS BY H. T. DUNN + + + New York + THE MACMILLAN COMPANY + 1911 + + _All rights reserved_ + + + COPYRIGHT, 1901, + BY THE COSMOPOLITAN MAGAZINE. + + COPYRIGHT, 1903, + BY P. F. COLLIER AND SON. + + COPYRIGHT, 1902, 1908, 1909, 1911, + BY THE CURTIS PUBLISHING COMPANY. + + COPYRIGHT, 1911, + BY THE MACMILLAN COMPANY. + + + Set up and electrotyped. Published May, 1911. + + + Norwood Press + J. S. Cushing Co.--Berwick & Smith Co. + Norwood, Mass., U.S.A. + + + + + To + + HORACE HOWARD FURNESS + + OF LINDENSHADE, WALLINGFORD + + + _That is my home of love: if I have rang’d, + Like him that travels, I return again._ + --SONNET CIX. + + + + +PREFACE + + +When this October comes, twenty years will be sped since the author of +these Western tales sat down one evening to begin his first tale of the +West, and--will you forgive him a preamble of gossip, of retrospection? +Time steps in between the now that is and the then that was with a +vengeance; it blocks the way for us all; we cannot go back. When the old +corner, the old place, the old house, wear the remembered look, beckon +to the memory as if to say, No change here! then verily is the change +worst, the shell most empty, the cheat well-nigh too piercing. In a +certain garden I used to plunder in 1866, the smell to-day of warm, +dusty strawberries.... But did we admit to our companionship ghosts +only, what would living be? I continue to eat strawberries. As for +smells, they’re worse than old melodies, I think. Lately I was the sport +of one. My train was trundling over the plains--a true train of the +past, half freight, half passenger, cars of an obsolete build, big +smoke-stack on the archaic engine, stops for meals, inveterate news-boy +with bad candy, bad novels, bad bananas--a dear old horrible train, when +magic was suddenly wrought. It came in through the open window, its +wand touched me, and the evoked spirits rose. With closed eyes I saw +them once more, standing there out in the alkali, the antelope by scores +and hundreds, only a little way off, a sort of color between cinnamon +and amber in the morning sun, transparent and phantom-like, with pale +legs. Only a little way off. Eyes closed, I watched them, as in 1885 +with open ones I beheld them first from the train. Now they were +running; I saw the bobbing dots of their white receding rears, and +through me passed the ghost of that first thrill at first seeing +antelope yesterday--it seemed yesterday: only a little way off. I opened +my eyes; there was the train as it ought to look, there were the plains, +the alkali, the dry gullies, the mounds, the flats, the enormous +sunlight, the virgin air like the first five measures of +_Lohengrin_--but where were the antelope? So natural did everything +continue to look, surely they must be just over that next rise! No; over +the one beyond that? No; only a little, little way off, but gone for +evermore! And magic smote me once again through the window. Thousands of +cattle were there, with horsemen. Were they not there? Not over the next +rise? No; gone for evermore. What was this magic that came in through +the window? The smell of the sage-brush. After several years it was +greeting me again. All day long it breathed a welcome and a sigh, as if +the desert whispered: Yes, I look as if I were here; but I am a ghost, +too, there’s no coming back. All day long the whiffs of sage-brush +conjured old sights before me, till my heart ran over with homesickness +for what was no more, and the desert seemed to whisper: It’s not I +you’re seeking, you’re straining your eyes to see yourself,--you as you +were in your early twenties, with your illusion that I, the happy +hunting-ground of your young irresponsibility, was going to be +permanent. You must shut your eyes to see yourself and me and the +antelope as we all used to be. Why, if Adam and Eve had evaded the angel +and got back into the garden, do you think they would have found it the +same after Cain and Abel? Thus moralized the desert, and I thought, How +many things we have to shut our eyes to see! + +Permanent! Living men, not very old yet, have seen the Indian on the +war-path, the buffalo stopping the train, the cow-boy driving his +cattle, the herder watching his sheep, the government irrigation dam, +and the automobile--have seen every one of these slides which progress +puts for a moment into its magic-lantern and removes to replace with a +new one. The final tale in this book could not possibly have happened in +the day of the first tale, although scarcely twenty years separate the +new, present Wyoming from that cow-boy Wyoming which then flourished so +boisterously, and is now like the antelope. Steam and electricity make +short work of epochs. We don’t know how many centuries the Indian and +the buffalo enjoyed before the trapper and pioneer arrived. These latter +had fifty or sixty good years of it, pushing westward until no west was +left to push to; a little beyond Ogden in 1869, the driving of that +golden spike which riveted the rails between New York and San Francisco, +rang out the old, rang in the new, and progress began to work its +magic-lantern faster. The soldier of the frontier, the frontier +post--gone; the cattle-range--gone; the sheep episode just come, yet +going already, or at any rate already mixed, diluted, with the farm, the +truck garden, the poultry yard, the wife, the telephone, the summer +boarder, and the Victor playing the latest Broadway “records” in valleys +where the august wilderness reigned silent--yesterday. The nomadic, +bachelor West is over, the housed, married West is established. This +rush of change, this speed we live at everywhere (only faster in some +places than in others) has led some one to remark sententiously that +when a Western baby is born, it immediately makes its will, while when a +New York baby is born, it merely applies for a divorce. + +But what changes can ever efface that early vision which began with the +antelope? Wyoming burst upon the tenderfoot resplendent, like all the +story-books, like Cooper and Irving and Parkman come true again; here, +actually going on, was that something which the boy runs away from +school to find, that land safe and far from Monday morning, nine +o’clock, and the spelling-book; here was Saturday eternal, where you +slept out-of-doors, hunted big animals, rode a horse, roped steers, and +wore deadly weapons. Make no mistake: fire-arms were at times practical +and imperative, but this was not the whole reason for sporting them on +your hip; you had escaped from civilization’s school-room, an air never +breathed before filled your lungs, and you were become one large shout +of joy. College-boy, farm-boy, street-boy, this West melted you all down +to the same first principles. Were you seeking fortune? Perhaps, +incidentally, but money was not the point; you had escaped from school. +This holiday was leavened by hard bodily work, manly deeds, and deeds +heroic, and beneath all the bright brave ripple moved the ground-swell +of tragedy. Something of promise, also, was in the air, promise of a +democracy which the East had missed:-- + +“With no spread-eagle brag do I gather conviction each year that we +Americans, judged not hastily, are sound at heart, kind, courageous, +often of the truest delicacy, and always ultimately of excellent good +sense. With such belief, or, rather, knowledge, it is sorrowful to see +our fatal complacence, our as yet undisciplined folly, in sending to our +State Legislatures and to that general business office of ours at +Washington, a herd of mismanagers that seems each year to grow more +inefficient and contemptible, whether branded Republican or Democrat. +But I take heart, because oftener and oftener I hear upon my journey the +citizens high and low muttering, ‘There’s too much politics in this +country’; and we shake hands.” + +Such “insurgent” sentiments did I in 1895, some time before insurgency’s +day, speak out in the preface to my first book of Western tales; to-day +my faith begins to be justified. In the West, where the heart of our +country has been this long while, and where the head may be pretty soon, +the citizens are awakening to the fact that our first century of “self” +government merely substituted the divine right of corporations for the +divine right of Kings. Surprising it is not, that a people whose genius +for machinery has always been paramount should expect more from +constitutions and institutions than these mere mechanisms of government +can of themselves perform; the initiative, referendum, and recall are +excellent inventions, but if left to run alone, as all our other patent +devices have been, they will grind out nothing for us: By his very creed +is the American dedicated to eternal vigilance. This we forgot for so +long that learning it anew is both painful and slow. We have further to +remember that prosperity is something of a curse in disguise; it is the +poor governments in history that have always been the purest; where +there is much to steal, there will be many to steal it. We must +discern, too, the illusion of “natural rights,” once an inspiration, now +a shell from which life has passed on into new formulas. A “right” has +no existence, save in its potential exercise; it does not proceed from +within, it is permitted from without, and “natural rights” is a phrase +empty of other meaning than to denote whatever primitive or acquired +inclinations of man each individual is by common consent allowed to +realize. These permissions have varied, and will vary, with the ages. +Polygamy would be called a natural right now in some parts of the world; +to the criminal and the diseased one wife will presently be forbidden in +many places. Let this single illustration serve. No argument based upon +the dogmatic premise of natural rights can end anywhere save in drifting +fog. We see this whenever a meeting of anarchists leads a judge or an +editor into the trap of attempting to define the “right” of free speech. +In fact, all government, all liberty, reduces itself to one man saying +to another: You may do _this_; but if you do _that_, I will kill you. +This power Democracy vests in “the people,” and our final lesson to +learn is that in a Democracy there is no such separate thing as “the +people”; all of us are the people. Truly his creed compels the American +to eternal vigilance! Will he learn to live up to it? + +From the West the tenderfoot took home with him the health he had +sought, and an enthusiasm his friends fled from; what was Wyoming to +them or they to Wyoming? In 1885 the Eastern notion of the West was +“Alkali Ike” and smoking pistols. No kind of serious art had presented +the frontier as yet. Fresh visits but served to deepen the tenderfoot’s +enthusiasm and whet his impatience that so much splendid indigenous +material should literally be wasting its sweetness on the desert air. It +is likely always to be true that in each hundred of mankind ninety-nine +can see nothing new until the hundredth shakes it in their faces--and he +must keep shaking it. No plan of shaking was yet in the tenderfoot’s +mind, he was dedicated to other calling; but he besieged the ears of our +great painter and our great novelist. He told the painter of the strong, +strange shapes of the buttes, the epic landscape, the color, the +marvellous light, the red men blanketed, the white men in chapareros, +the little bronze Indian children; particularly does he recall--in 1887 +or 1888--an occasion about two o’clock in the morning in a certain +beloved club in Boston, when he had been preaching to the painter. A +lesser painter (he is long dead) sat by, unbelieving. No, he said, don’t +go. I’m sure it’s all crude, repulsive, no beauty. But John Sargent did +believe. Other work waited him; his path lay elsewhere, he said, but he +was sure the tenderfoot spoke truth. Other work awaited the novelist, +too; both painter and novelist were wiser than to leave what they knew +to be their own for unknown fields. But would no one, then, disperse +the Alkali Ikes and bring the West into American art and letters? + +It was a happy day for the tenderfoot when he read the first sage-brush +story by Mary Hallock Foote. At last a voice was lifted to honor the +cattle country and not to libel it. Almost at the same moment Charles +King opened for us the door upon frontier military life. He brought +spirited army scenes to our ken, Mrs. Foote more generally clothed the +civilian frontier with serious and tender art. They (so far as I know) +were the first that ever burst into that silent sea. Next, Mr. Roosevelt +began to publish his vivid, robust accounts of Montana life. But words +alone, no matter how skilfully used, were not of themselves adequate to +present to the public a picture so strange and new. Another art was +needed, and most luckily the man with the seeing eye and shaping hand +arrived. + +A monument to Frederic Remington will undoubtedly rise some day; the +artist who more than any one has gathered up in a grand grasp an entire +era of this country’s history, and handed it down visible, living, +picturesque, for coming generations to see--such man will have a +monument. But in the manner of commemorating national benefactors, I +would we resembled the French who celebrate their great ones--not +soldiers and statesmen alone, but all their great ones--by naming public +places in their honor: the Quai Voltaire, the Rue Bizet, the Rue +Auber--to mention the first that come to memory. Everywhere in France +you will meet with these instances of a good custom. In this country we +seem to value even third-rate politicians more than first-rate men of +art and letters. If Paris can by her streets perpetuate the memory of +the composers of _Carmen_ and _Fra Diavolo_, would it not be fitting +that Denver, Cheyenne, Tucson, and other western cities, should have a +Remington street? I am glad I did not wait until he was dead to pay my +tribute to him. The two opportunities that came to me in his life I +took, nor has my opinion of his work changed since then. If he never +quite found himself in color, he was an incomparable draftsman; best of +all, he was a great wholesome force making for independence, and he +taught to our over-imitative American painters the needed lesson that +their own country furnishes subjects as worthy as any that Delacroix or +Millet ever saw. I have lived to see what I did not expect, the desert +on canvas; for which I thank Fernand Lungren. Tributes to the dead seem +late to me, and I shall take this chance to acknowledge my debt to some +more of the living. + +Four years after that night vigil with Sargent, the tenderfoot had still +written no word about the West. It was in 1891, after repeated +sojournings in camp, ranch, and military post, that his saturation with +the whole thing ran over, so to speak, in the form of fiction. Writing +had been a constant pastime since the school paper; in 1884 Mr. Howells +(how kind he was!) had felt my literary pulse and pronounced it +promising; a quickening came from the pages of Stevenson; a far stronger +shove next from the genius of _Plain Tales from the Hills_; during an +unusually long and broad wandering through the Platte valley, Powder +River, Buffalo, Cheyenne, Fort Washakie, Jackson’s Hole, and the Park, +the final push happened to be given by Prosper Mérimée; I had the volume +containing _Carmen_ with me. After reading it in the Park I straightway +invented a traveller’s tale. This was written down after I got home--I +left some good company at a club dinner table one night to go off to a +lonely library and begin it. A second followed, both were sent to +Franklin Square and accepted by Mr. Alden. Then I found my pretty +faithfully-kept Western diaries (they would now fill a shelf) to be a +reservoir of suggestion--and at times a source of despair; as, for +instance, when I unearthed the following abbreviations: Be sure to +remember Green-hides--perpendicular--sediment--Tuesdays as a rule. + +Aware of Mérimée’snot highly expansive nature, I should hesitate, were +he alive, to disclose my debt to his _Carmen_--my favorite of all short +stories; but Mr. Howells and Mr. Kipling will be indulgent, and there is +another who will have to bear with my gratitude. In 1896 I sat with him +and he went over my first book, patiently, minutely pointing out many +things. Everything that he said I could repeat this moment, and his own +pages have continued to give me hints without end. That the pupil in one +or two matters ventures to disagree with his benefactor may be from much +lingering ignorance, or because no two ever think wholly alike: _tot +homines quot sententiæ_, as the Latin grammar used so incontrovertibly +to remark. It is significant to note how this master seems to be +teaching a numerous young generation. Often do I pick up some popular +magazine and read a story (one even of murder, it may be, in tropic seas +or city slums) where some canny bit of foreshortening, of presentation, +reveals the spreading influence, and I say, Ah, my friend, never would +you have found out how to do that if Henry James hadn’t set you +thinking! + +It can happen, says Montesquieu, that the individual through pursuing +his own welfare contributes to the general good; Mr. Herbert Croly +admirably and sagaciously applies this thought to the case of the artist +and the writer. Their way to be worthy citizens and serve the State, he +says, is to see to it that their work be reverently thorough, for thus +they set high the standard of national excellence. To which I would add, +that a writer can easily take himself too seriously, but he can never +take his art too seriously. In our country, the painter and writer have +far outstripped the working-man in their ideal of honest work. This is +(partly) because painter and writer have to turn out a good product to +survive, while the working-man manages to survive with the least +possible of personal effort and skill. Did I offer my publisher such +work as the plumber and carpenter offer me, I should feel myself +disgraced. Are we to see the day when the slovenly, lazy poet shall +enact that the careful, industrious poet must work no longer and sell no +more than he? + +Editors have at times lamented to me that good work isn’t distinguished +from bad by our multifarious millions. I have the happiness to know the +editors to be wrong. Let the subject of a piece of fiction contain a +simple, broad appeal, and the better its art, the greater its success; +although the noble army of readers will not suspect that their pleasure +is largely due to the skill. Such a book as _The Egoist_, where the +subject is rarefied and complex, of course no height of art will render +acceptable, save to the rehearsed few. Thanks to certain of our more +robust editors, the noble army grows daily more rehearsed, reads +“harder” books than it did, accepts plainer speech and wider range of +subject than the skittish spinster generation of a while ago. But mark +here an underlying principle. The plain speech in Richardson was in his +day nothing to start back from; to-day it is inhibited by a change in +our circumambient reticence. The circumambient reticence varies in +degree with each race, and almost with every generation of each race. +Something like a natural law, it sets the limits for what can be said +aloud in grown-up company--and Art is speaking aloud in grown-up +company; it consists no more of the professional secrets of the doctor +than it does of the prattle of the nursery. Its business is indeed to +take notice of everything in life, but always subject to the +circumambient reticence. Those gentlemen (and ladies) who utter that +gaseous shibboleth about Art for Art (as well cry Beefsteak for +Beefsteak) and would have our books and plays be foul because Ben Jonson +frequently was and Anatole France frequently is, are out of their +reckoning; and generally they may be suspected not so much of an +abstract passion for truth as of a concrete letch for animalism. Almost +the only advice for the beginner is, Clearly feel what you intend to +express, and then go ahead, listening to nobody, unless to one who also +perceives clearly your intention. Great and small things does this rule +fit. Once in an early tale I sought to make our poor alphabet express +the sound of cow-bells, and I wrote that they _tankled_ on the hillside. +In the margin I stated my spelling to be intentional. Back it came in +the galley, tinkled. A revised proof being necessary, I restored my word +with emphasis--and lo, tinkle was returned me again. I appealed to the +veteran and well-loved sage at the head of _Harper’s Magazine_. He +supported me. Well, in the new Oxford dictionary, behold Tankle and me, +two flies in amber, perpetuated by that Supreme Court; I have coined a +new acknowledged word for the English language. This should not be told, +but for its small moral, and if I could not render a final set of thanks +to the living. Countless blunders have been saved me by the watchful eye +of the printer and proofreader, those friends I never see, whose names I +do not know. For twenty years they have marked places where through +carelessness or fatigue I have slipped; may some of them know through +this page that I appreciate their service. + +This book is three years late; the first tale designed for it was +published in 1901. Its follower should even now be ready. It is not yet +begun; it exists merely in notes and intentions. Give me health and a +day, sighs Emerson; and I am sorry for all who have to say that. When +you see the new moon over your left shoulder, wish always for health; +never mind all the other things. I own to an attachment for the members +of this family; I would fain follow their lives a little more, into +twentieth century Wyoming, which knows not the cow-boy, and where the +cow-boy feels at times more lost than ever he was on the range. Of all +the ills that harass writing, plans deferred seem at times the worst; +yet great pleasures offset them--the sight of one’s pages in a foreign +tongue, meeting horses in the Rocky Mountains named after the members +of one’s family, being asked from across the world for further news of +some member. Lately a suggestion full of allurement came from one who +had read of Sir Francis, the duchess, and the countess, in the _Saturday +Evening Post_. (There, by the way, is an intrepid editor!) Why not add, +said the reader, a third lady to the group in Jimsy’s pond, and see what +they would all do then? Only consider the possibilities! But I dare not. +Life, without whose gifts none of us could have a story to tell--not +even Scheherezadè--life presented to me Sir Francis and his adoring +household. Never could I risk trusting to invention in a matter so +delicate. Would the duchess and the countess unite to draw the line at +the added sister? Would Sir Francis rise to the emergency? and if so, +what line would he take? The added sister might prove a lamb, a minx, or +a vixen. You see the possibilities. Dearly should I like to return this +summer to the singing waters of Buffalo Horn, and place a third lady in +that pond of Jimsy’s; then we might have another story if others are +ever to be. My science in the third tale is of course out of date; since +Kelvin, energy is immortal no longer, and a _lower_ form of it was +transmitted to the Secretary than was originally stored in Captain +Stone. + + + + +CONTENTS + + + PAGE + + I. HAPPY-TEETH 27 + + II. SPIT-CAT CREEK 67 + + III. IN THE BACK 89 + + IV. TIMBERLINE 124 + + V. THE GIFT HORSE 159 + + VI. EXTRA DRY 207 + + VII. WHERE IT WAS 229 + +VIII. THE DRAKE WHO HAD MEANS OF HIS OWN 276 + + + + +LIST OF ILLUSTRATIONS + + +“‘Pie like Mother made,’ said Scipio” _Frontispiece_ + + FACING PAGE + +“High Bear galloped away into the dusk” 56 + +“Out of the door he flew,--squaws and bucks flapped after +him like poultry” 66 + +“‘Is Sistah Stone heah?’ Leonidas inquired” 108 + +“‘If that I was where I would be, then should I be where I am +not’” 126 + +“_Waiting for nothing_ was stamped plain upon him from head +to foot” 140 + +“The stage rattled up as I sat” 171 + +“I found nothing new--the plain, the sage-brush, the dry +ground--no more” 188 + +“He shuffled the shells straight at the freighter as if he were +making love to him” 216 + +“How could he know that Bellyful had only become a road-agent +in the last ten minutes?” 226 + +“‘My, but it’s turrable easy to get married’” 284 + +“‘Well, Jimsy, are you going to get me any wood for this stove--or +ain’t you?’” 296 + + + + +I + +HAPPY-TEETH + + +Scipio Le Moyne lay in bed, held together with bandages. His body had +need for many bandages. A Bar-Circle-Zee three-year-old had done him +violent mischief at the forks of Stinking Water.[1] But for the fence, +Scipio might have swung clear of the wild, rearing animal. When they +lifted his wrecked frame from the ground one of them had said:-- + +“A spade’s all he’ll need now.” + +Overhearing this with some still unconquered piece of his mind, Scipio +made one last remark: “I ain’t going to die for years and years.” + +Upon this his head had rolled over, and no further statements came from +him for--I forget how long. Yet somehow, we all believed that last +remark of his. + +“Since I’ve known him,” said the Virginian, “I have found him a truthful +man.” + +“Which don’t mean,” Honey Wiggin put in, “that he can’t lie when he +ought to.” + +Judge Henry always sent his hurt cow-punchers to the nearest surgical +aid, which in this case was the hospital on the reservation. Here then, +one afternoon, Scipio lay, his body still bound tight at a number of +places, but his brain needing no bandages whatever; he was able to see +one friend for a little while each day. It was almost time for this +day’s visitor to go, and the visitor looked at his watch. + +“Oh, don’t do that!” pleaded the man in bed. “I’m not sick any more.” + +“You will be sick some more if you keep talking,” replied the Virginian. + +“Thinkin’ is a heap more dangerous, if y’u can’t let it out,” Scipio +urged. “I’m not half through tellin’ y’u about Horacles.” + +“Did his mother name him that?” inquired the Virginian. + +“Naw! but his mother brought it on him. Didn’t y’u know? Of course you +don’t often get so far north in the Basin as the Agency. His name is +Horace Pericles Byram. Well, the Agent wasn’t going to call his +assistant store-clerk all that, y’u know, not even if he _has_ got an +uncle in the Senate of the United States. Couldn’t spare the time. Days +not long enough. Not even in June. So everybody calls him Horacles now. +He’s reconciled to it. But I ain’t. It’s too good for him. A heap too +good. I’ve knowed him all my life, and I can’t think of a name that’s +not less foolish than he is. Well, where was I? I was tellin’ y’u how +back in Gallipol_eece_ he couldn’t understand anything. Not dogs. Not +horses. Not girls.” + +“Do you understand girls?” the Virginian interrupted. + +“Better’n Horacles. Well, now it seems he can’t understand Indians. Here +he is sellin’ goods to ’em across the counter at the Agency store. I +could sell twiced what he does, from what they tell me. I guess the +Agent has begun to discover what a trick the Uncle played him when he +unloaded Horacles on him. Now why did the Uncle do that?” + +Scipio stopped in his rambling discourse, and his brows knitted as he +began to think about the Uncle. The Virginian once again looked at his +watch, but Scipio, deep in his thoughts, did not notice him. “Uncle,” he +resumed to himself, half aloud, “Uncle was the damnedest scoundrel in +Gallipol_eece_.--Say!” he exclaimed suddenly, and made an eager movement +to sit up. “Oh Lord!” he groaned, sinking back. “I forgot.--What’s your +hurry?” + +But the Virginian had seen the pain transfix his friend’s face, and +though that face had instantly smiled, it was white. He stood up. “I’d +ought to get kicked from here to the ranch,” he said, remorsefully. +“I’ll get the doctor.” + +Vainly the man in bed protested; his visitor was already at the door. + +“I’ve not told y’u about his false teeth!” shrieked Scipio, hoping this +would detain him. “And he does tricks with a rabbit and a bowl of fish.” + +But the guest was gone. In his place presently the Post surgeon came, +and was not pleased. Indeed, this excellent army doctor swore. Still, it +was not the first time that he had done so, nor did it prove the last; +and Scipio, it soon appeared, had given himself no hurt. But in answer +to a severe threat, he whined:-- + +“Oh, ain’t y’u goin’ to let me see him to-morro’?” + +“You’ll see nobody to-morrow except me.” + +“Well, that’ll be seein’ nobody,” whined Scipio, more grievously. + +The doctor grinned. “In some ways you’re incurable. Better go to sleep +now.” And he left him. + +Scipio did not go to sleep then, though by morning he had slept ten +healthful hours, waking with the Uncle still at the centre of his +thoughts. It made him again knit his brows. + +“No, you can’t see him to-day,” said the doctor, in reply to a request. + +“But I hadn’t finished sayin’ something to him,” Scipio protested. “And +I’m well enough to see my dead grandmother.” + +“That I’ll not forbid,” answered the doctor. And he added that the +Virginian had gone back to Sunk Creek with some horses. + +“Oh, yes,” said Scipio. “I’d forgot. Well, he’ll be coming through on +his way to Billings next week. You been up to the Agency lately? +Yesterday? Well, there’s going to be something new happen. Agent seem +worried or anything?” + +“Not that I noticed. Are the Indians going on the war-path?” + +“Nothing like that. But why does a senator of the United States put his +nephew in that store? Y’u needn’t to tell me it’s to provide for him, +for it don’t provide. I thought I had it figured out last night, but +Horacles don’t fit. I can’t make him fit. He don’t understand Injuns. +That’s my trouble. Now the Uncle must know Horacles don’t understand. +But if he didn’t know?” pursued Scipio, and fell to thinking. + +“Well,” said the doctor indulgently, as he rose, “it’s good you can +invent these romances. Keeps you from fretting, shut up here alone.” + +“There’d be no romances here,” retorted Scipio. “Uncle is exclusively +hard cash.” The doctor departed. + +At his visit next morning, he was pleased with his patient’s condition. +“Keep on,” said he, “and I’ll let you sit up Monday for ten minutes. Any +more romances?” + +“Been thinkin’ of my past life,” said Scipio. + +The doctor laughed long. “Why, how old are you, anyhow?” he asked at +length. + +“Oh, there’s some lovely years still to come before I’m thirty. But I’ve +got a whole lot of past life, all the same.” Then he pointed a solemn, +oracular finger at the doctor. “What white man savvys the Injun? Not +you. Not me. And I’ve drifted around some, too. The map of the United +States has been my home. Been in Arizona and New Mexico and among the +Siwashes--seen all kinds of Injun--but I don’t savvy ’em. I know most +any Injun’s better’n most any white man till he meets the white man. Not +smarter, y’u know, but better. And I do know this: You take an Injun and +let him be a warrior and a chief and a grandfather who has killed heaps +of white men in his day--but all that don’t make him grown up. Not like +we’re grown up. He stays a child in some respects till he’s dead. He’ll +believe things and be scared at things that ain’t nothin’ to you and me. +You take Old High Bear right on this reservation. He’s got hair like +snow and eyes like an eagle’s and he can sing a war-song about fights +that happened when our fathers were kids. But if you want to deal with +him, you got to remember he’s a child of five.” + +“I do know all this,” said the doctor, interested. “I’ve not been twenty +years on the frontier for nothing.” + +“Horacles don’t know it,” said Scipio. “I’ve saw him in the store all +season.” + +“Well,” said the doctor, “see you to-morrow. I’ve some new patients in +the ward.” + +“Soldiers?” + +“Soldiers.” + +“Guess I know why they’re here.” + +“Oh, yes,” sighed the doctor. “You know. Few come here for any other +reason.” The doctor held views about how a military post should be +regulated, which popular sentiment will never share. “Can I do anything +for you?” he inquired. + +“If I could have some newspapers?” said Scipio. + +“Why didn’t you tell me before?” said the doctor. After that he saw to +it that Scipio had them liberally. + +With newspapers the patient sat surrounded deep, when the Virginian, +passing north on his way to Billings, looked in for a moment to give his +friend the good word. That is what he came for, but what he said was:-- + +“So he has got false teeth?” + +Scipio, hearing the voice at the door, looked over the top of his paper +at the visitor. + +“Yes,” he replied, precisely as if the visitor had never been out of the +room. + +“What d’ y’u know?” inquired the Virginian. + +“Nothing; what do you?” + +“Nothing.” + +After all, such brief greetings cover the ground. + +“Better sit down,” suggested Scipio. + +The Virginian sat, and took up a paper. Thus for a little while they +both read in silence. + +“Did y’u stop at the Agency as y’u came along?” asked Scipio, not +looking up from his paper. + +“No.” + +There was silence again as they continued reading. The Virginian, just +come from Sunk Creek, had seen no newspapers as recent as these. When +two friends on meeting after absence can sit together for half an hour +without a word passing between them, it is proof that they really enjoy +each other’s company. The gentle air came in the window, bringing the +tonic odor of the sage-brush. Outside the window stretched a yellow +world to distant golden hills. The talkative voice of a magpie somewhere +near at hand was the only sound. + +“Nothing in the newspapers in particular,” said Scipio, finally. + +“You expaictin’ something particular?” the Virginian asked. + +“Yes.” + +“Mind sayin’ what it is?” + +“Wish I knew what it is.” + +“Always Horacles?” + +“Always him--and Uncle. I’d like to spot Uncle.” + +Mess call sounded from the parade ground. It recalled the flight of time +to the Virginian. + +“When you get back from Billings,” said Scipio, “you’re liable to find +me up and around.” + +“Hope so. Maybe you’ll be well enough to go with me to the ranch.” + +But when the Virginian returned, a great deal had happened all at once, +as is the custom of events. + +Scipio’s vigorous convalescence brought him in the next few days to +sitting about in the open air, and then enlarged his freedom to a +crutch. He hobbled hither and yon, paying visits, many of them to the +doctor. The doctor it was, and no newspaper, who gave to Scipio the +first grain of that “something particular” which he had been daily +seeking and never found. He mentioned a new building that was being put +up rather far away down in the corner of the reservation. The rumor in +the air was that it had something to do with the Quartermaster’s +department. The odd thing was that the Quartermaster himself had heard +nothing about it. The Agent up at the Agency store considered this +extremely odd. But a profound absence of further explanations seemed to +prevail. What possible need for a building was there at that +inconvenient, isolated spot? + +Scipio slapped his leg. “I guess what y’u call my romance is about to +start.” + +“Well,” the doctor admitted, “it may be. Curious things are done upon +Indian reservations. Our management of them may be likened to putting +the Lord’s Prayer and the Ten Commandments into a bag and crushing them +to powder. Let our statesmen at Washington get their hands on an Indian +reservation, and not even honor among thieves remains.” + +“Say, doc,” said Scipio, “when d’ y’u guess I can get off?” + +“Don’t be in too much of a hurry,” the doctor cautioned him. “If you go +to Sunk Creek--” + +“Sunk Creek! I only want to go to the Agency.” + +“Oh, well, you could do that to-day--but don’t you want to see the +entertainment? Conjuring tricks are promised.” + +“I want to see Horacles.” + +“But he is the entertainment. Supper comes after he’s through.” + +Scipio stayed. He was not repaid, he thought. “A poor show,” was his +comment as he went to bed. He came later to be very glad indeed that he +had gone to that entertainment. + +The next day found him seated in the Agency store, being warmly greeted +by his friends the Indians. They knew him well; perhaps he understood +them better than he had said. By Horacles he was not warmly greeted; +perhaps Horacles did not wish to be understood--and then, Scipio, in his +comings and goings through the reservation, had played with Horacles for +the benefit of bystanders. There is no doubt whatever that Horacles did +not understand Scipio. He was sorry to notice how the Agent, his +employer, shook Scipio’s hand and invited him to come and stop with him +till he was fit to return to his work. And Scipio accepted this +invitation. He sat him down in the store, and made himself at home. Legs +stretched out on one chair, crutch within reach, hands comfortably +clasped round the arms of the chair he sat in, head tilted back, eyes +apparently studying the goods which hung from the beams overhead, he +visibly sniffed the air. + +“Smell anything you don’t like?” inquired the clerk, tartly--and +unwisely. + +“Nothin’ except you, Horacles,” was the perfectly amiable +rejoinder.--“It’s good,” Scipio then confessed, “to be smellin’ buckskin +and leather and groceries instead of ether and iodoform.” + +“Guess you were pretty sick,” observed the clerk, with relish. + +“Yes. Oh, yes. I was pretty sick. That’s right. Yes.” Scipio had +continued through these slowly drawled remarks to look at the ceiling. +Then his glance dropped to the level of Horacles, and keenly fixed that +unconscious youth’s plump little form, pink little face, and mean little +mustache. Behind one ear stuck a pen, behind the other a pencil, as the +assistant clerk was arranging some tins of Arbuckle’s Arioso coffee. +Then Scipio took aim and fired: “So you’re going to quit your job?” + +Horacles whirled round. “Who says so?” + +The chance shot--if there ever is such a thing, if such shots are not +always the result of visions and perceptions which lie beyond our +present knowledge--this chance shot had hit. + +“First I’ve heard of it,” then said Horacles sulkily. “Guess you’re +delirious still.” He returned to his coffee, and life grew more +interesting than ever to Scipio. + +Instead of trickling back, health began to rush back into his long +imprisoned body, and though he could not fully use it yet, and though if +he hobbled a hundred yards he was compelled to rest it, his wiry mind +knew no fatigue. How athletic his brains were was easily perceived by +the Indian Agent. The convalescent would hobble over to the store after +breakfast and hail the assistant clerk at once. “Morning, Horacles,” he +would begin; “how’s Uncle?”--“Oh, when are you going to give us a new +joke?” the worried Horacles would retort.--“Just as soon as you give us +a new Uncle, Horacles. Or any other relation to make us feel proud we +know you. What did his letter last night say?” The second or third time +this had been asked still found Horacles with no better repartee than +angry silence. “Didn’t he send me his love?” Scipio then said; and still +the hapless Horacles said nothing. “Well, y’u give him mine when you +write him this afternoon.”--“I ain’t writing this afternoon,” snapped +the clerk.--“You’re not! Why, I thought you wrote each other every +day!” This was so near the truth that Horacles flared out: “I’d be +ashamed if I’d nothing better to do than spy on other people’s mails.” + +Thus by dinner-time generally an audience would be gathered round Scipio +where he sat with his legs on the chair, and Horacles over his ledger +would be furiously muttering that “Some day they would all see.” + +Horacles asked for a couple of days’ holiday, and got it. He wished to +hunt, he said. But the Agent happened to find that he had been to the +railroad about some freight. This he mentioned to Scipio. “I don’t know +what he’s up to,” he said. He had found that worrying Horacles was +merely one of the things that Scipio’s brains were good for; Scipio had +advised him prudently about a sale of beeves, and had introduced a +simple contrivance for luring to the store the customers whom Horacles +failed to attract. It was merely a free lunch counter,--cheese and +crackers every day, and deviled ham on pay-day,--but it put up the daily +receipts. + +And next, one evening after the mail was in, Scipio, sitting alone in +the front of the store, saw the Agent, sitting alone in the back of the +store, spring suddenly from his chair, crush a newspaper into his +pocket, and stride out to his house. At breakfast the Agent spoke thus +to Scipio:-- + +“I must go to Washington. I shall be back before they let you and your +leg run loose. Will you do something for me?” + +“Name it. Just name it.” + +“Run the store while I’m gone.” + +“D’ y’u think I can?” + +“I know you can. There’ll be no trouble under you. You understand +Indians.” + +“But suppose something turns up?” + +“I don’t think anything will before I’m back. I’d sooner leave you than +Horacles in charge here. Will you do it and take two dollars a day?” + +“Do it for nothing. Horacles’ll be compensation enough.” + +“No, he won’t.--And see here, he can’t help being himself.” + +“Enough said. I’ll strive to pity him. None of us was consulted about +being born. And I’ll keep remembering that we was both raised at +Gallipol_eece_, Ohio, and that he inherited a bigger outrage of a name +than I did. That’s what comes of havin’ a French ancestor.--Only, he +used to steal my lunch at school.” And Scipio’s bleached blue eye grew +cold. Later injuries one may forgive, but school ones never. + +“Didn’t you whale him?” asked the Agent. + +“Every time,” said Scipio, “till he told Uncle. Uncle was mayor of +Gallipol_eece_ then. So I wasn’t ready to get expelled,--I got ready +later; nothin’ is easier than gettin’ expelled,--but I locked up my +lunch after that.” + +“Uncle’s pretty good to him,” muttered the Agent. “Got him this +position.--Well, nobody will expel you here. Look after things. I’ll +feel easy to think you’re on hand.” + +For that newspaper which the Agent had crushed into his pocket, Scipio +searched cracks and corners, but searched in vain. A fear quite +unreasoning possessed him for a while: could he but learn what was in +the paper that had so stirred his patron, perhaps he could avert +whatever the thing was that he felt in the air, threatening some sort of +injury. He knew himself resourceful. Dislike of Horacles and Uncle had +been enough to start his wish to thwart them--if there was anything to +thwart; but now pride and gratitude fired him; he had been trusted; he +cared more to be trusted than for anything on earth; he must rise equal +to it now! The Agent had evidently taken the paper away with him--and so +Scipio absurdly read all the papers. He collected old ones, and laid his +hands upon the new the moment they were out of the mail-bag. It may be +said that he lived daily in a wrapping of newspapers. + +“Why, you have got Horacles laughing at you.” + +This the observant Virginian pointed out to Scipio immediately on his +arrival from Billings. Scipio turned a sickened look upon his friend. +The look was accompanied by a cold wave in his stomach. + +“Y’u cert’nly have,” the remorseless friend pursued. “I reckon he must +have had a plumb happy time watchin’ y’u still-hunt them newspapers. Now +who’d ever have foretold you would afford Horacles enjoyment?” + +In a weak voice Scipio essayed to fight it off. “Don’t you try to +hoodwink me with any of your frog lies.” + +“No need,” said the Virginian. “From the door as I came in I saw him at +his desk lookin’ at y’u easy-like. ’Twas a right quaint pictyeh--him +smilin’ at the desk, and your nose tight agaynst the Omaha _Bee_. I +thought first y’u didn’t have a handkerchief.” + +“I wonder if he has me beat?” muttered poor Scipio. + +The Virginian now had a word of consolation. “Don’t y’u see,” he again +pointed out, “that no newspaper could have helped you? If it could why +did he go away to Washington without tellin’ you? He don’t look for you +to deal with troubles he don’t mention to you.” + +“I wonder if Horacles has me beat?” said Scipio once more. + +The Virginian standing by the seated, brooding man clapped him twice on +the shoulders, gently. It was enough. They were very fast friends. + +“I know,” said Scipio in response. “Thank y’u. But I’d hate for him to +have me beat.” + +It was the doctor who now furnished information that would have relieved +any reasonable man from a sense of failure. The doctor was excited +because his view of our faith in Indian matters was again justified by a +further instance. + +“Oh, yes!” he said. “Just give those people at Washington time, and +every step they’ve taken from the start will be in the mud puddle of a +lie. Uncle’s in the game all right. He’s been meditating how to serve +his country and increase his income. There’s a railroad at the big end +of his notion, but the entering wedge seems only to be a new store down +in the corner of this reservation. You see, it has been long settled by +the sacredest compacts that two stores shall be enough here--the +Post-trader’s and the Agent’s--but the dear Indians need a third, Uncle +says. He has told the Senate and the Interior Department and the White +House that a lot of them have to travel too far for supplies. So now +Washington is sure the Indians need a third store. The Post-trader and +the Agent are stopping at the Post to-night. They got East too late to +hold up the job. If Horacles opens that new store, the Agent might just +as well shut up his own.” + +“Ain’t y’u going to look at my leg?” was all the reply that Scipio made. + +The doctor laughed. It was to examine the leg that he had come, and he +had forgotten all about it. “You can forget all about it, too,” he told +Scipio when he had finished. “Go back to Sunk Creek when you like. Go +back to full work next week, say. Your wicked body is sound again. A +better man would unquestionably have died.” + +But the cheery doctor could not cheer the unreasonable Scipio. In the +morning the complacent little Horacles made known to all the world his +perfected arrangements. Directly the Agent had safely turned his back +and gone to Washington, his disloyal clerk had become doubly busy. He +had at once perceived that this was a comfortable time for him to hurry +his new rival store into readiness and be securely established behind +its counter before his betrayed employer should return. In this last he +might not quite succeed; the Agent had come back a day or two sooner +than Horacles had calculated, but it was a trifle; after all, he had +carried through the small part of his uncle’s scheme which he had been +sent here to do. Inside that building in the far corner of the +reservation, once rumored to be connected with the Quartermaster’s +department, he would now sell luxuries and necessities to the Indians at +a price cheaper than his employer’s, and his employer’s store would +henceforth be empty of customers. Perhaps the sweetest moment that +Horacles had known for many weeks was when he said to Scipio:-- + +“I’m writing Uncle about it to-day.” + +That this should have gone on under his nose while he sat searching the +papers was to Scipio utterly unbearable. His mind was in a turmoil, +feeling about helplessly but furiously for vengeance; and the +Virginian’s sane question--What could he have done to stop it if he had +discovered it?--comforted him not at all. They were outside the store, +sitting under a tree, waiting for the returning Agent to appear. But he +did not come, and the suspense added to Scipio’s wretchedness. + +“He put me in charge,” he kept repeating. + +“The driver ain’t responsible when a stage is held up,” reasoned the +Virginian. + +Scipio hardly heard him. “He put me in charge,” he said. Then he worked +round to Horacles again. “He ain’t got strength. He ain’t got beauty. He +ain’t got riches. He ain’t got brains. He’s just got sense enough for +parlor conjuring tricks--not good ones, either. And yet he has me beat.” + +“He’s got an uncle in the Senate,” said the Virginian. + +The disconsolate Scipio took a pull at his cigar,--he had taken one +between every sentence. “Damn his false teeth.” + +The Virginian looked grave. “Don’t be hasty. Maybe the day will come +when you and me’ll need ’em to chew our tenderloin.” + +“We’ll be old. Horacles is twenty-five.” + +“Twenty-five is certainly young to commence eatin’ by machinery,” +admitted the Virginian. + +“And he’s proud of ’em,” whined Scipio. “Proud! Opens his bone box and +sticks ’em out at y’u on the end of his tongue.” \ No newline at end of file diff --git a/src/test/java/io/zipcoder/ParenCheckerTest.java b/src/test/java/io/zipcoder/ParenCheckerTest.java index 76aa3b6..83e2c68 100644 --- a/src/test/java/io/zipcoder/ParenCheckerTest.java +++ b/src/test/java/io/zipcoder/ParenCheckerTest.java @@ -5,4 +5,40 @@ public class ParenCheckerTest { + @Test + public void addToStackTestWithoutSpaces() { + ParenChecker parenChecker = new ParenChecker(); + parenChecker.add("h el l o"); + String actual = parenChecker.getCharString(); + Assert.assertEquals("[h, e, l, l, o]", actual); + } + + @Test + public void addToStackTestReal() { + ParenChecker parenChecker = new ParenChecker(); + parenChecker.add("()()() /// 31"); + String actual = parenChecker.getCharString(); + Assert.assertEquals("[(, ), (, ), (, ), /, /, /, 3, 1]", actual); + } + + @Test + public void isOpenTest1() { + ParenChecker parenChecker = new ParenChecker(); + parenChecker.add("()()() /// 31"); + Assert.assertFalse(parenChecker.isOpen()); + } + + @Test + public void isOpenTest2() { + ParenChecker parenChecker = new ParenChecker(); + parenChecker.add("hegd(dfsg)dfsg((( '' ' \" \""); + Assert.assertTrue(parenChecker.isOpen()); + } + + @Test + public void isOpenTest3() { + ParenChecker parenChecker = new ParenChecker(); + parenChecker.add("()()() {} [] '' \" \" "); + Assert.assertFalse(parenChecker.isOpen()); + } } \ No newline at end of file diff --git a/src/test/java/io/zipcoder/TestSuite.java b/src/test/java/io/zipcoder/TestSuite.java new file mode 100644 index 0000000..b37ce97 --- /dev/null +++ b/src/test/java/io/zipcoder/TestSuite.java @@ -0,0 +1,11 @@ +package io.zipcoder; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ + ParenCheckerTest.class, WCTest.class +}) +public class TestSuite { +} diff --git a/src/test/java/io/zipcoder/WCTest.java b/src/test/java/io/zipcoder/WCTest.java index 895e831..6116422 100644 --- a/src/test/java/io/zipcoder/WCTest.java +++ b/src/test/java/io/zipcoder/WCTest.java @@ -2,10 +2,80 @@ import org.junit.Assert; import org.junit.Test; - +import java.io.*; import java.util.ArrayList; -import java.util.Arrays; public class WCTest { + @Test + public void operationTest1() { + WC wc = new WC(WC.class.getResource("/theBook.txt").getFile()); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStream)); + wc.program(); + Assert.assertNotNull(outputStream); + } + + @Test + public void operationTest2() { + WC wc = new WC(WC.class.getResource("/documentationDef.txt").getFile()); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStream)); + wc.program(); + String expected = "Word: use | Occurrences: 1\n" + + "Word: to | Occurrences: 2\n" + + "Word: the | Occurrences: 3\n" + + "Word: substantiation; | Occurrences: 1\n" + + "Word: referring | Occurrences: 1\n" + + "Word: provision | Occurrences: 2\n" + + "Word: or | Occurrences: 3\n" + + "Word: of | Occurrences: 3\n" + + "Word: objective | Occurrences: 1\n" + + "Word: in | Occurrences: 1\n" + + "Word: historical | Occurrences: 2\n" + + "Word: footnotes, | Occurrences: 1\n" + + "Word: facts | Occurrences: 1\n" + + "Word: evidence | Occurrences: 2\n" + + "Word: documents | Occurrences: 2\n" + + "Word: documentary | Occurrences: 2\n" + + "Word: containing | Occurrences: 1\n" + + "Word: conformity | Occurrences: 1\n" + + "Word: b | Occurrences: 1\n" + + "Word: appendices, | Occurrences: 1\n" + + "Word: also | Occurrences: 1\n" + + "Word: addenda | Occurrences: 1\n" + + "Word: a | Occurrences: 1\n" + + "Word: : | Occurrences: 5\n"; + Assert.assertEquals(outputStream.toString(), expected); + } + + @Test + public void getOccTest(){ + ArrayList words = new ArrayList(); + words.add("Hello"); + words.add("Hello"); + words.add("Hello"); + words.add("Yo"); + words.add("hahahahahaa"); + WC wc = new WC(); + Assert.assertEquals(3, wc.getOccurrences("Hello", words)); + } + + @Test + public void fillTreeMapTest(){ + ArrayList words = new ArrayList(); + words.add("Hello"); + words.add("Hello"); + words.add("Hello"); + words.add("Yo"); + words.add("hahahahahaa"); + WC wc = new WC(words.iterator()); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStream)); + wc.program(); + String expected = "Word: hahahahahaa | Occurrences: 1\n" + + "Word: Yo | Occurrences: 1\n" + + "Word: Hello | Occurrences: 3\n"; + Assert.assertEquals(expected, outputStream.toString()); + } } \ No newline at end of file