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...
-
If global warming persists, how would it affect shipping and transportation routes? You can probably list some of the dangers of global warming but how may it actually benefit the economies of some...
-
What is a compensating control? Give some examples for finance and investment cycle accounts.
-
Why are relationships so important?
-
Upon graduation from high school, William Nitter accepted a job as a plumbers assistant for a large local plumbing company. After three years of hard work, William received a plumbing licence and...
-
amazon (answers will be on file below) Accounts Receivable: a) Are sales primarily on credit or in cash?b) What is the relative size of accounts receivable?How has this changed over the last...
-
This step requires you to complete some exceptions testing for the Employee p-card expenditures for the year ended 12/31/2023. Required: a. How many unique employees exceeded their annual authorized...
-
You have been asked to perform a stock valuation prior to the annual shareholders' meeting next week. The two models you have selected to value the firm are the dividend discount model and the...
-
Pure securities and asset pricing under uncertainty: a.What is a "pure security" and why are they important? We have derived the price of the pure security as (this is also in your book): =(1)(1())....
-
Over the last two decades, pharmaceutical companies have been slowly increasing their leverage. For example, in 2001, Merck had a Debt to Capitalizationratio of 0.30; Pfizer had a Debt to...
-
4. Based on Table 2, which call option contract will have the highest premium? Table 2: Option Premium Option Strike Price A $40 B $42 C $44 If the option contract is a put option, which has the...
-
Amazon Tires produces custom tires. The company's average cost per tire is $160.00 when it produces 2,000 tires per month. If $120,000 of the total cost is fixed, What is the variable cost of...
-
The cost of work in process in Department Y at May 31 has been determined to be $113,500. Process costing system-journal entries Recreate the following table and prepare a general journal...
-
[The following information applies to the questions displayed below.] Golden Corporation's current year income statement, comparative balance sheets, and additional information follow For the year,...
-
Explain the differences and similarities between fringe benefits and salary as forms of compensation.
-
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...
-
The Spivak Company was involved in the following treasury stock transactions during 20xx: a. Purchased 80,000 shares of its $1 par value common stock on the market for $2.50 per share. b. Purchased...
-
The Clockwork Corporation had the following stock outstanding from 20x6 through 20x9: Preferred stock: $100 par value, 8 percent cumulative, 10,000 shares authorized, issued, and outstanding Common...
-
Vanowski, Inc., was organized and authorized to issue 10,000 shares of $100 par value, 9 percent preferred stock and 100,000 shares of no-par, $5 stated value common stock on July 1, 20xx....
Study smarter with the SolutionInn App