7. What are the problems of the following code for data model and observers when a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
7. What are the problems of the following code for data model and observers when a new observer is to be added? What kinds of design patterns may be used to improve it? Can you provide the code to add a new observer like LineChartView? (20 points) class TableView { } void update (double [] values) { System.out.print ("Table ["); for (double v : values ) { } } System.out.print (v + ", "); System.out.println("1"); class BarChartView { } void update (double [] values) { System.out.print ("Bar["); for (double v : values ) { } System.out.print (v + ", "); System.out.println("1"); public class DataModel { private double [] values = new double [] {0.1, 0.4, 0.3, 0.2}; private TableView table; private Bar ChartView barchart; { public void attachTable (TableView t) { table = t; } public void attachBarchart (BarChartView b) } barchart = b; public void notify (double [] newvalues) { values = newvalues; table.update (values) ; barchart.update (values); } 7. What are the problems of the following code for data model and observers when a new observer is to be added? What kinds of design patterns may be used to improve it? Can you provide the code to add a new observer like LineChartView? (20 points) class TableView { } void update (double [] values) { System.out.print ("Table ["); for (double v : values ) { } } System.out.print (v + ", "); System.out.println("1"); class BarChartView { } void update (double [] values) { System.out.print ("Bar["); for (double v : values ) { } System.out.print (v + ", "); System.out.println("1"); public class DataModel { private double [] values = new double [] {0.1, 0.4, 0.3, 0.2}; private TableView table; private Bar ChartView barchart; { public void attachTable (TableView t) { table = t; } public void attachBarchart (BarChartView b) } barchart = b; public void notify (double [] newvalues) { values = newvalues; table.update (values) ; barchart.update (values); }
Expert Answer:
Related Book For
International Marketing And Export Management
ISBN: 9781292016924
8th Edition
Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr
Posted Date:
Students also viewed these programming questions
-
Trusted software could then be run on the workstation. Discuss the advisability of this approach to workstation design. (10 marks) b) Explain how distributed inter-process communication (IPC) is...
-
Data set Theory Assume an informational record with one association parent including matches (a, b) where a can't try not to be a parent of b. (a) Write a Datalog demand which gives the graph of...
-
Cungs Dress Delivery operates a mail-order business that sells clothes designed for frequent travelers. It had sales of $610,000 in December. Because Cungs Dress Delivery is in the mail order...
-
The costs listed below are related to a manufacturer of all-natural ice cream. In the space provided, indicate whether the cost should be classified as direct materials (DM), direct labor (DL), or...
-
Max enjoys windsurfing and snorkeling. Max has $35 a day to spend, and he can spend as much time as he likes on his leisure pursuits. The price of renting equipment for windsurfing is $10 an hour and...
-
The dataset NFLContracts 2015 contains the yearly salary (in millions of dollars) from the contracts of all players on a National Football League (NFL) roster at the start of the 2015 season. (a) Use...
-
The unadjusted trial balance of Avery Air Purification System at December 31, 2018, and the data needed for the adjustments follow. Adjustment data at December 31 follow: a. On December 15, Avery...
-
Identify the characteristics of the logarithmic function below. If a value is a non-integer then type it as a reduced fraction. f(x) = log(15 - 5x) +6 The domain is The range is The vertical...
-
3/ Select all the factors that must be considered when selecting the appropriate benchmark in peer-benchmarking? (select all the correct answers) a. Airport location b. Airport manager's experience...
-
Barbara and Fred have decided to put in an automatic sprinkler system at their cabin. They have requested bids, and the lowest price received is \($5\),500 from Water Systems Inc (WSI). They decide...
-
What single sum of money at the end of year 3 is equivalent to a payment series of \($10\),000 the first year, \($9\),000 the second year, . . . ,down to \($6\),000 the fifth year? Assume that money...
-
If your TVOM is 15 percent and your friends is 20 percent, can the two of you work out mutually satisfactory terms for a 1-year $3,000 loan? Assume the lender has the money available and neither...
-
Based on Baders inflation expectations as shown in Exhibit 1, purchasing power parity implies that which of the following countries currencies should depreciate, all else being equal? A. Country A B....
-
RT is about to loan his granddaughter Cynthia $20,000 for 1 year. RTs TVOM, based upon his current investment earnings, is 8 percent. Cynthias TVOM, based upon earnings on investments, is 12 percent....
-
Explain the differences, importance, and purpose of both the codeof conduct and the code of ethics. Secondly, what are some of the factors that you would use to make ethical hiring decisions in an...
-
Listed below are common types of current liabilities, contingencies, and commitments: a. Accounts payable b. Bank loans and commercial paper c. Notes payable d. Dividends payable e. Sales and excise...
-
The Woberg Company, located near Aarhus, Denmark, manufactured dishwashers and garbage pulverizers for home use, and cooking equipment and commercial pulverizers for restaurants. A relatively young...
-
Select a culture with which you have had contact. How does it differ from your own culture? How might these differences affect international marketing activities, business negotiations or ongoing...
-
Who are the key stakeholders for Bayonne Ham, Feta Cheese, and Champagne?
-
A sample contains radioactive atoms of two types, A and B. Initially there are five times as many A atoms as there are B atoms. Two hours later, the numbers of the two atoms are equal. The half-life...
-
About \(12 \%\) of your body mass is carbon; some of this is radioactive \({ }^{14} \mathrm{C}\), a beta-emitter. If you absorb \(100 \%\) of the\(49 \mathrm{keV}\) energy of each \({ }^{14}...
-
You are assisting in an anthropology lab over the summer by carrying out \({ }^{14} \mathrm{C}\) dating. \(\mathrm{A}\) graduate student found a bone he believes to be 20,000 years old. You extract...
Study smarter with the SolutionInn App