Question: Write a second constructor as indicated. Sample output: User1: Minutes: 0, Messages: 0 User2: Minutes: 1000, Messages: 5000 // ===== Code from file PhonePlan.java =====

Write a second constructor as indicated. Sample output:

User1: Minutes: 0, Messages: 0 User2: Minutes: 1000, Messages: 5000 

// ===== Code from file PhonePlan.java ===== public class PhonePlan { private int freeMinutes; private int freeMessages;

public PhonePlan() { freeMinutes = 0; freeMessages = 0; }

// FIXME: Create a second constructor with numMinutes and numMessages parameters.

/* Your solution goes here */

public void print() { System.out.println("Minutes: " + freeMinutes + ", Messages: " + freeMessages); return; } } // ===== end =====

// ===== Code from file CallPhonePlan.java ===== public class CallPhonePlan { public static void main (String [] args) { PhonePlan user1Plan = new PhonePlan(); // Calls default constructor PhonePlan user2Plan = new PhonePlan(1000, 5000); // Calls newly-created constructor

System.out.print("User1: "); user1Plan.print();

System.out.print("User2: "); user2Plan.print();

return; } } // ===== end =====

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!