Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a. The Talk-A-Lot Cell Phone Company provides phone services for its customers.

ID: 3813928 • Letter: A

Question

a. The Talk-A-Lot Cell Phone Company provides phone services for its customers. Create an abstract class named PhoneCall that includes a String field for a phone number and a double field for the price of the call. Also include a constructor that requires a phone number parameter and that sets the price to 0.0. Include a set method for the price. Also include three abstract get methods—one that returns the phone number, another that returns the price of the call, and a third that displays information about the call. Create two child classes of PhoneCall: IncomingPhoneCall and OutgoingPhoneCall. The IncomingPhoneCall constructor passes its phone number parameter to its parent’s constructor and sets the price of the call to 0.02. The method that displays the phone call information displays the phone number, the rate, and the price of the call (which is the same as the rate). The OutgoingPhoneCall class includes an additional field that holds the time of the call in minutes. The constructor requires both a phone number and the time. The price is 0.04 per minute, and the display method shows the details of the call, including the phone number, the rate per minute, the number of minutes, and the total price. Write an application that demonstrates you can instantiate and display both IncomingPhoneCall and OutgoingPhoneCall objects. Save the files as PhoneCall.java, IncomingPhoneCall.java, OutgoingPhoneCall.java, and DemoPhoneCalls.java.

b. Write an application in which you assign data to a mix of 10 Incoming Phone Call and Outgoing Phone Call objects into an array. Use a for loop to display the data. Save the file as PhoneCallArray.java.

I have already tried making the codes. I need someone to look over please!

//DemoPhoneCall.java
public class DemoPhoneCalls
{
   public static void main(String[] args)
   {
PhoneCall somecall[] = new PhoneCall[10];
int x;
somecall[0] = new IncomingPhoneCall("123-895-7542");
somecall[1] = new OutgoingPhoneCall("254-986-5324",25);
somecall[2] = new IncomingPhoneCall("157-789-5421");
somecall[3] = new OutgoingPhoneCall("154-853-1235",90);
somecall[4] = new IncomingPhoneCall("125-894-6584");
somecall[5] = new OutgoingPhoneCall("234-859-6548",250);
somecall[6] = new IncomingPhoneCall("236-986-5214");
somecall[7] = new IncomingPhoneCall("546-235-6987");
somecall[8] = new IncomingPhoneCall("231-856-9854");
somecall[9] = new IncomingPhoneCall("946-589-7985");

for(x = 0; x < somecall.length; ++x)
System.out.println("Phone Number: " + somecall[x].getPhoneNumber() + " costs $" + somecall[x].getPrice());
   }

}//End of DemoPhoneCall

----------------------------------------------------------------------------------------------------------------------------------------------------------

//IncomingPhoneCall.java

public class IncomingPhoneCall extends PhoneCall
{
   public IncomingPhoneCall(String phonenumber)
   {
super(phonenumber);
setPrice();
   }

public void setPrice()
{
   price = 0.02;
}

void showInfo()
{
   System.out.println("Phonenumber: " + getPhoneNumber() + " $"+getPrice());
   }
}//End of IncomingPhoneCall class

----------------------------------------------------------------------------------------------------------------------------------------------------------

//OutgoingPhoneCall.java

public class OutgoingPhoneCall extends PhoneCall
{
   int time;

public OutgoingPhoneCall(String phonenumber , int time )
{
   super(phonenumber);
   setPrice();
   this.time =time;
}

public void setPrice()
{
   price = 0.04;
}

void showInfo()
{
   System.out.println("Phonenumber: " + getPhoneNumber() + "rate per min is $"+getPrice()+"number of minutes is "+time+"total price is "+(time*price));
   }
}//End of OutgoingPhoneCall class

----------------------------------------------------------------------------------------------------------------------------------------------------------

//PhoneCall.java

abstract class PhoneCall
{
   private String phonenumber;
   double price;

public PhoneCall(String phonenumber)
{
   this.phonenumber = phonenumber;
   this.price = 0.0;
}

public String getPhoneNumber()
{
   return phonenumber;
}

public double getPrice()
{
   return price;
}

public abstract void setPrice();
}//End of PhoneCall class

----------------------------------------------------------------------------------------------------------------------------------------------------------

//PhoneCallArray.java
public class PhoneCallArray
{
   public static void main(String[] args)
   {

   //Create an array of incoming calls type
   PhoneCall[] incomingPhoneCalls
   =new IncomingPhoneCall[10];

   incomingPhoneCalls[0]= new IncomingPhoneCall("671-637-4566");
   incomingPhoneCalls[1]= new IncomingPhoneCall("671-633-0500");
   incomingPhoneCalls[2]= new IncomingPhoneCall("671-632-4222");
   incomingPhoneCalls[3]= new IncomingPhoneCall("671-472-0560");
   incomingPhoneCalls[4]= new IncomingPhoneCall("671-969-2801");
   incomingPhoneCalls[5]= new IncomingPhoneCall("671-475-8382");
   incomingPhoneCalls[6]= new IncomingPhoneCall("671-988-6070");
   incomingPhoneCalls[7]= new IncomingPhoneCall("671-686-4476");
   incomingPhoneCalls[8]= new IncomingPhoneCall("671-633-8801");
   incomingPhoneCalls[9]= new IncomingPhoneCall("671-788-0628");

   System.out.println("Incoming Calls Information");
   //print incoming calls
   for (PhoneCall phoneCall : incomingPhoneCalls) {
   System.out.println(phoneCall.getCallInformation());
   }

   //Create an array of outgoing calls type
   PhoneCall[] outgoingPhoneCalls
   =new OutgoingPhoneCall[10];

   //set outgoing calls with phone number and number of minutes
   outgoingPhoneCalls[0]= new OutgoingPhoneCall("671-637-4566",1);
   outgoingPhoneCalls[1]= new OutgoingPhoneCall("671-633-0500",2);
   outgoingPhoneCalls[2]= new OutgoingPhoneCall("671-632-4222",3);
   outgoingPhoneCalls[3]= new OutgoingPhoneCall("671-472-0560",4);
   outgoingPhoneCalls[4]= new OutgoingPhoneCall("671-475-8382",5);
   outgoingPhoneCalls[5]= new OutgoingPhoneCall("671-988-6070",6);
   outgoingPhoneCalls[6]= new OutgoingPhoneCall("671-686-4476",7);
   outgoingPhoneCalls[7]= new OutgoingPhoneCall("671-633-8801",8);
   outgoingPhoneCalls[8]= new OutgoingPhoneCall("671-788-0628",9);
   outgoingPhoneCalls[9]= new OutgoingPhoneCall("671-969-2801",10);


   System.out.println("Outgoing Calls Information");

   //print outgoing calls
   for (PhoneCall phoneCall : outgoingPhoneCalls)
   {
   System.out.println(phoneCall.getCallInformation());
   }
   }
}//End of PhoneCallArray class

Explanation / Answer

HI, You have implemented correctly.

THese shpuld be the content of file according to question

#######################

//DemoPhoneCalls.java

public class DemoPhoneCalls

{

   public static void main(String[] args)

   {

   //Create an array of incoming calls type

   IncomingPhoneCall[] incomingPhoneCalls

   =new IncomingPhoneCall[10];

   incomingPhoneCalls[0]= new IncomingPhoneCall("671-637-4566");

   incomingPhoneCalls[1]= new IncomingPhoneCall("671-633-0500");

   incomingPhoneCalls[2]= new IncomingPhoneCall("671-632-4222");

   incomingPhoneCalls[3]= new IncomingPhoneCall("671-472-0560");

   incomingPhoneCalls[4]= new IncomingPhoneCall("671-969-2801");

   incomingPhoneCalls[5]= new IncomingPhoneCall("671-475-8382");

   incomingPhoneCalls[6]= new IncomingPhoneCall("671-988-6070");

   incomingPhoneCalls[7]= new IncomingPhoneCall("671-686-4476");

   incomingPhoneCalls[8]= new IncomingPhoneCall("671-633-8801");

   incomingPhoneCalls[9]= new IncomingPhoneCall("671-788-0628");

   System.out.println("Incoming Calls Information");

   //print incoming calls

   for (IncomingPhoneCall phoneCall : incomingPhoneCalls) {

   phoneCall.showInfo();

   }

   //Create an array of outgoing calls type

   OutgoingPhoneCall[] outgoingPhoneCalls

   =new OutgoingPhoneCall[10];

   //set outgoing calls with phone number and number of minutes

   outgoingPhoneCalls[0]= new OutgoingPhoneCall("671-637-4566",1);

   outgoingPhoneCalls[1]= new OutgoingPhoneCall("671-633-0500",2);

   outgoingPhoneCalls[2]= new OutgoingPhoneCall("671-632-4222",3);

   outgoingPhoneCalls[3]= new OutgoingPhoneCall("671-472-0560",4);

   outgoingPhoneCalls[4]= new OutgoingPhoneCall("671-475-8382",5);

   outgoingPhoneCalls[5]= new OutgoingPhoneCall("671-988-6070",6);

   outgoingPhoneCalls[6]= new OutgoingPhoneCall("671-686-4476",7);

   outgoingPhoneCalls[7]= new OutgoingPhoneCall("671-633-8801",8);

   outgoingPhoneCalls[8]= new OutgoingPhoneCall("671-788-0628",9);

   outgoingPhoneCalls[9]= new OutgoingPhoneCall("671-969-2801",10);

   System.out.println("Outgoing Calls Information");

   //print outgoing calls

   for (OutgoingPhoneCall phoneCall : outgoingPhoneCalls)

   {

   phoneCall.showInfo();

   }

   }

}//End of PhoneCallArray class

###################################

//PhoneCallArray.java

public class PhoneCallArray

{

   public static void main(String[] args)

   {

       PhoneCall somecall[] = new PhoneCall[10];

       int x;

       somecall[0] = new IncomingPhoneCall("123-895-7542");

       somecall[1] = new OutgoingPhoneCall("254-986-5324",25);

       somecall[2] = new IncomingPhoneCall("157-789-5421");

       somecall[3] = new OutgoingPhoneCall("154-853-1235",90);

       somecall[4] = new IncomingPhoneCall("125-894-6584");

       somecall[5] = new OutgoingPhoneCall("234-859-6548",250);

       somecall[6] = new IncomingPhoneCall("236-986-5214");

       somecall[7] = new IncomingPhoneCall("546-235-6987");

       somecall[8] = new IncomingPhoneCall("231-856-9854");

       somecall[9] = new IncomingPhoneCall("946-589-7985");

       for(x = 0; x < somecall.length; ++x)

           System.out.println("Phone Number: " + somecall[x].getPhoneNumber() + " costs $" + somecall[x].getPrice());

   }

}//End of PhoneCallArray class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote