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); } } // ===== 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(); } } // ===== end =====
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);
}
}
// ===== 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();
}
}
// ===== end =====
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images