Word has the class diagram shown to the left. Set the class constants to the val-...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Word has the class diagram shown to the left. Set the class constants to the val- nes 0, 1, and 2 when you declare them. Use the name of the constants in your code (in all classes) since that makes the code eas- ier to read. Initialize sort Criterion with ORIGINAL when you declare it. The instance variables the Word and count are initialized in the constructor. getCount() and get Word() return the values of count and the Word. set Criterion(arg) changes the value of sortCriterion to one of the class constants and get Criterion () returns its value. compare To(arg) should always return 2 if sortCriterion == ORIGINAL. Otherwise, it compares two instances of Word either by the values of the Word or by those of count. Which one, depends on the value of sort Criterion. If sort Criterion equals BYNAME, compare To(arg) should compare the values of the Word alphabetically. Use the instance. method compareTo(..) of String with the same name as yours (which compares two instances of Word) to compare the values of both strings the Word alphabetically. If sort Criterion equals BYCOUNTS, then your compare To(..) method should compare the values of count numerically. For these two criteria, your compare To(arg) method should send back one of the possible values -1, 0, or 1. It should return a value -1 if the value of the instance variable (either count or the Word) of the calling instance of Word is smaller than that of arg in the argument list of compare To(arg). It should return 0 if the values of the instance variables match. If the value of the instance variable of the calling instance is larger than that of its counterpart in arg, compare To(arg) should return 1. to String() returns a formatted string. It starts with "Word:" followed by the value of word in a column 10 characters wide and aligned to the right. You leave 3 empty spaces and write "Count:" followed by the value of count in a column 3 characters wide. Word +ORIGINAL, BYNAME, BYCOUNTS: int -theWord: String -count: int -sortCriterion: int +Word (String, int) +getCount): int +getWord(): String +setCriterion(int): void +getCriterion(): int +compareTo(Word): int +toString(): String Word has the class diagram shown to the left. Set the class constants to the val- nes 0, 1, and 2 when you declare them. Use the name of the constants in your code (in all classes) since that makes the code eas- ier to read. Initialize sort Criterion with ORIGINAL when you declare it. The instance variables the Word and count are initialized in the constructor. getCount() and get Word() return the values of count and the Word. set Criterion(arg) changes the value of sortCriterion to one of the class constants and get Criterion () returns its value. compare To(arg) should always return 2 if sortCriterion == ORIGINAL. Otherwise, it compares two instances of Word either by the values of the Word or by those of count. Which one, depends on the value of sort Criterion. If sort Criterion equals BYNAME, compare To(arg) should compare the values of the Word alphabetically. Use the instance. method compareTo(..) of String with the same name as yours (which compares two instances of Word) to compare the values of both strings the Word alphabetically. If sort Criterion equals BYCOUNTS, then your compare To(..) method should compare the values of count numerically. For these two criteria, your compare To(arg) method should send back one of the possible values -1, 0, or 1. It should return a value -1 if the value of the instance variable (either count or the Word) of the calling instance of Word is smaller than that of arg in the argument list of compare To(arg). It should return 0 if the values of the instance variables match. If the value of the instance variable of the calling instance is larger than that of its counterpart in arg, compare To(arg) should return 1. to String() returns a formatted string. It starts with "Word:" followed by the value of word in a column 10 characters wide and aligned to the right. You leave 3 empty spaces and write "Count:" followed by the value of count in a column 3 characters wide. Word +ORIGINAL, BYNAME, BYCOUNTS: int -theWord: String -count: int -sortCriterion: int +Word (String, int) +getCount): int +getWord(): String +setCriterion(int): void +getCriterion(): int +compareTo(Word): int +toString(): String
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these operating system questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Portray in words what transforms you would have to make to your execution to some degree (a) to accomplish this and remark on the benefits and detriments of this thought.You are approached to compose...
-
The SEC criticized Frank Sinopoli for not sending an audit inquiry letter to Geo Securities external legal counsel. Describe the nature and purpose of such a letter. Do you agree with the SEC that...
-
The portfolio manager of Ludwig Company has excess cash that is to be invested for four years. He can purchase four-year Treasury notes that offer a 9 percent yield. Alternatively, he can purchase...
-
On January 1, 2010, Aye buys 500 shares of Que, a public company, for $1.20 per share. On January 4, 2011, Aye buys 200 shares of Are, a public company for $0.84 per share. On September 1, 2012, Aye...
-
Consider an underlying linear model, \(y_{i}^{*}=\mathbf{x}_{i}^{\prime} \boldsymbol{\beta}+\epsilon_{i}^{*}\), where \(\epsilon_{i}^{*}\) is normally distributed with mean zero and variance...
-
Connor Chemical Company's plant processes batches of organic chemical products through three stages after starting with raw materials: (1) Mixing and blending, (2) Reaction chamber, and (3)...
-
You are approached to comment on a company's accounting disclosure quality. As an accounting analyst, what are the factors will you consider in your assessment and why?
-
Jim and Joel have come to you to get an appraisal to lease their property. Using the information below, complete the following questions: Answer the below questions according to the property details...
-
Cassandra made a substantial profit when she bought and then sold 10 puts on the TSX 300 index. How did the Canadian market perform? a. cannot be determined b. his altar C. rejected d. appreciated
-
Briefly describe the difference between equity funding and debt financing.
-
Describe the four primary factors that play a role in determining the nature and intensity of the bargaining power of buyers. How does the bargaining power of buyers have the potential to suppress an...
-
Define the term core competency and describe why its important for a firm to have one or more core competencies. How do a companys core competencies help shape its business model?
-
Describe the most common sources of equity funding.
-
What is meant by the term customer interface? Explain how Dell and Hewlett-Packard differ from each other on this core dimension.
-
Q: Do as directed (also write the Algorithm/Pseudocode, if explicitly mentioned in the question) Insert the following keys in Binary Search Tree: {9, 4, 15, 2, 20, 6, 1, 21, 10, 3} Traverse the above...
-
The text defined intrinsic value as the value of an asset given a hypothetically complete understanding of the assets investment characteristics. Discuss why hypothetically is included in the...
-
Ann hires a nanny to watch her two children while she works at a local hospital. She pays the 19-year-old nanny $125 per week for 48 weeks during the current year. a. What is the employer's portion...
-
Frank Willingham has the following transactions during the year: Sale of office equipment on March 15 that cost $20,000 when purchased on July 1, 2010. Frank has claimed $5,000 in depreciation and...
-
Jerry made the following contributions during 2012: His synagogue (by check).....................................................$680 The Democratic Party (by check)...
-
Determine whether each of the following statements is true or false: Critical thinking can be improved by asking yourself a series of questions about any issue or problem you encounter. These...
-
Determine whether each of the following statements is true or false: Most business decisions are now based on gut feelings and hunches, rather than being data-driven.
-
Determine whether each of the following statements is true or false: The globalization of business has little bearing on management accounting.
Study smarter with the SolutionInn App