Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Provide the code for the following method so that it: - Adds to the ArrayList the subscription passed as parameter if it is NOT

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 {

Step by Step Solution

3.44 Rating (160 Votes )

There are 3 Steps involved in it

Step: 1

public class SubscriptionsList private ArrayList subs private double bu... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

1. Show enthusiasm for the subject you teach.

Answered: 1 week ago