Here is the code I have thus far: (5) The \"Fun\" Part Now we will create a coup
ID: 3785057 • Letter: H
Question
Here is the code I have thus far:
(5) The "Fun" Part Now we will create a couple of interesting methods. Create an instance method in the Customer class called phone0 which records a phone call being made between two customers. The method should take 2 parameters. The first should be a Customer object, representing the customer that this person is calling. The second parameter is the number of callLength minutes that the phone call lasted (minimum one minute Note from part 2 that this method is used as follows: rob .phone (sue 12) a 12 minute call from Rob's phone to Sue's phone You must complete the code for the method so that the following happens: 1. If either customer has a "pay-as-you-go" plan and the number of callLength minutes exceeds the minutesRemaining for either "pay-as-you-go" customer, then the call is not allowed nothing happens 2. After the method is called, both customers' minutesUsed amounts should increase by callLength minutes 3. If the call was successful, each customers' number of callsMade should increase by 1 Now write a method called buyMinutes() which simulates a customer purchasing extra minutes of phone usage. The method should take a single integer parameter representing the number of minutes that are being purchased If the customer has a "pay-as-you-go" plan, then helshe is charged $0.40 per minute purchased (i.e., add it immediately to the balance) and you must update the PhonePlan and Customer objects accordingly. For regular plan customers, this method does nothing Finally, write an instance method in the Customer class called accessinternet0 which records that a customer has just accessed the internet and used up some data. The method should take one parameter representing the number of KB that was used during his/her internet session. Note from part 2 that this method is used as follows:Explanation / Answer
Here I am explaining the instance method for access internet and I observed that other instances are explained.
According to the program, we need to record the customer’s internet accessing details.
We are using the isReachable method to achieve this functionality.
We are using the Java standard for dealing with connection errors: IOExceptions.
When our program must send data, the underlying API will certainly throw an IOE in the case the network is down.
If our program expects data, instead, use a timeout or something like that to detect possible errors in the network stack and report it to the user.