ITS 245 – Integrative Programming Lab 06 – inheritance & Aggregation (100 points) Objectives: 1. To understand the relationships between objects 2. To learn to implement object inheritance and...

source C lab


ITS 245 – Integrative Programming Lab 06 – inheritance & Aggregation (100 points) Objectives: 1. To understand the relationships between objects 2. To learn to implement object inheritance and aggregation Short Questions: Q1. Explain why aggregation is important in software development Q2. Describe how an object is passed as a parameter to a method of another object. For example, when the CellularPhone’s non-default constructor is invoked Tasks: Write a syntactically and semantically correct C# program that models telephones. Your program must be a Console Application. The Class Diagram (continued on the next two pages): +Telephone() +Telephone(in maker : string, in phoneModel : string, in number : string) +Manufacturer() : string +Model() : string +PhoneNumber() : string +display() +dial(in number : string) +handUp() +redial() -manufacturer : string -model : string -isConnected : bool = false -phoneNumber : string -lastNumberDialed : string Telephone +LandLinePhone() +LandLinePhone(in manufacturer : string, in model : string, in phoneNumber : string, in hasCord : bool) +HasCord() : bool +display() -hasCord : bool LandLinePhone +CellularPhone() +CellularPhone(in manufacturer : string, in model : string, in phoneNumber : string, in technology : string, in hasCamera : bool, in callerId : CallerId) +Technology() : string +HasCamera() : bool +CallerID() : CallerId +sendTextMessage(in callNumber : string, in messageText : string) +display() -technology : string -hasCamera : bool -callerId : CallerId CellularPhone +CallerId() +CallerId(in callerName : string, in callerPhoneNumber : string) +CallerName() : string +CallerPhoneNumber() : string +ToString() : string -callerName : string -callerPhoneNumber : string CallerId 1 * The Telephone Class The display( ) method outputs the data stored in a Telephone object in the following format. Manufacturer: VTech Model: V 9090 Phone Number: 219-555-9999 The dial( ) method outputs the following. Connecting to from ... Connected. where and are phone numbers. The handUp( ) method outputs the following. Disconnected. The redial( ) method outputs the following. Reconnecting to from ... Connected. where and are phone numbers. Both dial( ) and redial( ) methods should check to see if the phone is being used (connected). If it is connected, your code should warn the user that the line is being used (see the sample run output). The LandLinePhone Class This class inherits the Telephone class. There is an overridden method named display( ) which prints the data stored in a LandLinePhone object in the following format. Manufacturer: VTech Model: V-4321 Phone Number: 219-999-2345 Cordless: Yes All the lines except the last one of the output are from calling display( ) method of the base class (Telephone). Please also refer to the sample run output for the output format. The CellPhone Class This class inherits Telephone calss. There is an overridden method named display( ) which prints the data stored in a CellPhone object in the following format. Manufacturer: Motorola Model: RZAR Phone Number: 219-000-9999 Technology: CDMA Has Camera: Yes Caller ID: John Doe: 909-888-7654 All the lines except the last three of the output are from calling display( ) method of the base class. Please also refer to the sample run output for the output format. The CallerId Class There is a class used to store a caller ID. The ToString( ) is an overridden method from the object class, and it returns a string of caller name and caller phone number in the following format. John Doe: 909-888-7654 The Main( ) Method This is the method in the Program class to test the CallerId and Telephone objects. First, you need to create a CallerId object using the default constructor. Create an object named “myCellPhone” to hold a CellPhone object using the default constructor. Create an object called “yourHomePhone” to hold a LandLinePhone object using the non-default constructor. Prompt the user for myCellPhone data as shown in the sample run output. After accepting the phone and text for short text message, call display( ) and sendTextMessage( ) methods on myCellPhone object. Prompt the user for a number to call from your home phone (yourHomePhone). Call dial( ) method and redial( ) method, and then handUp( ). Note: Please use the proper coding style. Deliverables: Two files need to be submitted: 1) An electronic copy of your lab report 2) A zip file including all the project files with your source code in it. Note: please attach these two files SEPERATELY in your submission. Don’t compress the lab report into your zipped folder. Output of Sample Runs (underscored items are user input) === myCellPhone === Enter the Cell Phone Manufacturer: Motorola Enter the Cell Phone Model: RAZR Enter the Cell Phone Technology: CDMA Does it Have a Built-in Camera [Y or N]: y Enter the Phone # of Your Cell Phone: 219-000-9999 Enter the Person's Name in the Caller Id: John Doe Enter the Phone # in the Caller Id: 909-888-7654 Enter the short text message you wish to send: Hello, I am home. Enter the Number you wish to send the text message: 1-800-PURDUE1 Manufacturer: Motorola Model: RAZR Phone Number: 219-000-9999 Technology: CDMA Has Camera: Yes Caller ID: John Doe: 909-888-7654 Sending the following message to 1-800-PURDUE1... Hello, I am home. === yourHomePhone === Enter the Number you wish to call from the landline: 1-877-PUCPUC1 Manufacturer: VTech Model: V-4321 Phone Number: 219-999-2345 Cordless: Yes Connecting to 1-877-PUCPUC1 from 219-999-2345... Connected. You are still connected. Please hand up first. Disconnected. Press any key to continue . . . ITS245 – Lab06 1 of 5 _1405160920.vsd +Telephone() +Telephone(in maker : string, in phoneModel : string, in number : string) +Manufacturer() : string +Model() : string +PhoneNumber() : string +display() +dial(in number : string) +handUp() +redial() -manufacturer : string -model : string -isConnected : bool = false -phoneNumber : string -lastNumberDialed : string Telephone Static Structure +LandLinePhone() +LandLinePhone(in manufacturer : string, in model : string, in phoneNumber : string, in hasCord : bool) +HasCord() : bool +display() -hasCord : bool LandLinePhone +CellularPhone() +CellularPhone(in manufacturer : string, in model : string, in phoneNumber : string, in technology : string, in hasCamera : bool, in callerId : CallerId) +Technology() : string +HasCamera() : bool +CallerID() : CallerId +sendTextMessage(in callNumber : string, in messageText : string) +display() -technology : string -hasCamera : bool -callerId : CallerId CellularPhone +CallerId() +CallerId(in callerName : string, in callerPhoneNumber : string) +CallerName() : string +CallerPhoneNumber() : string +ToString() : string -callerName : string -callerPhoneNumber : string CallerId 1 *
Oct 02, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here