Provide the code for the following method so that it: - Adds to the ArrayList the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Provide the code for the following method so that it: - Adds to the ArrayList the subscription passed as parameter if it is NOT of type Paid Subscription (.5 point) If it is of type PaidSubscription, then only add it if its price will not put us over our budget (.5 point). If you end up adding it, also update the cost attribute so as to reflect how much we have spent so far (.5 point) */ public void add (Subscription s) { for (Subscription i: subs) { if(i instanceof Subscription) { this.subs.add(s); }if() { this.subs.add(s); }//end method add - /* TASK #6 - 3 points Provide the code for the following method so that it:[ Creates a File object corresponding to the parameter filename (0.5 point) Uses it to test if the file actually already exists (0.5 point) If it does, we will raise the Subscriptions ListException with a message indicating "File already exists" (0.5 point). Creates a Printwriter object that will be automatically closed (0.5 point) Uses it to write to the file each of the subscriptions contained in our ArrayList (0.5 point). Catches any exceptions that may be thrown and rethrows instead a Subscriptions ListException with a message corresponding to the toString of the exception object (0.5 point). public void save(String filename) throws Subscriptions ListException { Provide the code for the following method so that it: - Adds to the ArrayList the subscription passed as parameter if it is NOT of type Paid Subscription (.5 point) If it is of type PaidSubscription, then only add it if its price will not put us over our budget (.5 point). If you end up adding it, also update the cost attribute so as to reflect how much we have spent so far (.5 point) */ public void add (Subscription s) { for (Subscription i: subs) { if(i instanceof Subscription) { this.subs.add(s); }if() { this.subs.add(s); }//end method add - /* TASK #6 - 3 points Provide the code for the following method so that it:[ Creates a File object corresponding to the parameter filename (0.5 point) Uses it to test if the file actually already exists (0.5 point) If it does, we will raise the Subscriptions ListException with a message indicating "File already exists" (0.5 point). Creates a Printwriter object that will be automatically closed (0.5 point) Uses it to write to the file each of the subscriptions contained in our ArrayList (0.5 point). Catches any exceptions that may be thrown and rethrows instead a Subscriptions ListException with a message corresponding to the toString of the exception object (0.5 point). public void save(String filename) throws Subscriptions ListException {
Expert Answer:
Answer rating: 100% (QA)
public class SubscriptionsList private ArrayList subs private double bu... View the full 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 programming questions
-
Below is the code and the output from the code running. I need help with the Subscription list class. More specifcally the add method. This code created an arraylist of objects and i am not sure how...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
The boundedness theorem shows how the bottom row of a synthetic division is used to place upper and lower bounds on possible real zeros of a polynomial function. Let P(x) define a polynomial function...
-
Worthmore Bank and Trust is considering giving Madsen Company a loan. Before doing so, it decides that further discussions with Madsens accountant may be desirable. One area of particular concern is...
-
Lead has a face-centered cubic lattice with all atoms at lattice points and a unit-cell edge length of 495.0 pm. Its atomic mass is 207.2 amu. What is the density of lead?
-
You are flying at \(0.99 c\) with respect to Kara. At the exact instant you pass Kara, she fires a very short laser pulse in the same direction you're heading. a. After \(1.0 \mathrm{~s}\) has...
-
Five college seniors with majors in accounting are discussing alternative career plans. The first senior plans to become an internal revenue agent because his primary interest is income taxes. He...
-
Describe the motivation, industry relevance, objectives, and work plan for the project focused on Metabolic Engineering of Saccharomyces cerevisiae for efficient hydrolysis of cellulose.
-
The Ocean City water park is considering the purchase of a new log flume ride. The cost to purchase the equipment is 1,800,000, and it will cost an additional 180,000 to have it installed. The...
-
(9%) Problem 3: A block of mass m is initially at rest at the top of an inclined plane, which has a height of 5.2 m and has an angle of 0-29 with respect to the horizontal. After it has been...
-
Third (3rd) Mid-Term Extra Bonus Credit Question...... In Chapter 5, ("Elasticity And It's Applications), Figure 9 (page 105), highlights how Supply, Demand & Elasticity can be used to address...
-
Toki ltalian inspired restaurants Consult with at least one relevant personnel to manage stock and complete the following: Discuss information on losses and resolutions for stock Identify at least...
-
The binding construct let defines Scheme block structure. In a let expression, the initial values are computed before any of the variables become bound. Evaluate these expressions by hand showing the...
-
You want to borrow $15,550 from your big sister to purchase a used Jeep Wrangler (its got both a hard and soft top!good deal!). She agrees and makes a deal with you to charge you 3.75% interest...
-
The contribution margin ratio of Kuck Corporation's only product is 6 3 % . The company's monthly fixed expense is $ 4 5 6 , 4 0 0 and the company's monthly target profit is $ 4 2 , 4 0 0 . Required:...
-
I had 29 marbles, some red and some blue, but Billy stole most of them from me! Billy took 3/4 of the red marbles and 2/3 of the blue marbles. Now I only have 9 marbles. Did Billy take more red...
-
Which property determines whether a control is available to the user during run time? a. Available b. Enabled c. Unavailable d. Disabled
-
John Williams (age 42) is a single taxpayer, and he lives at 1324 Forest Dr., Reno, NV 89501. His Social Security number is 555-94-9358. John's earnings and withholdings as the manager of a local...
-
Janie graduates from high school in 2012 and enrolls in college in the fall. Her parents pay $4,000 for her tuition and fees. a. Assuming Janie's parents have AGI of $170,000, what is the American...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
You are managing the development of a case tracking system project for your large law firm. The requirements phase of the project is almost complete, and preliminary design work has begun. The...
-
At the conclusion of this chapter, the textbook mentions that data and process modeling may eventually become obsolete due to the increasing popularity and usage of object-oriented modeling and...
-
Although data and process models depict the same system with different views, systemi designers must synchronize these different views to make sure that their models are consistent and complete. One...
Study smarter with the SolutionInn App