Ask a question to Desklib · AI bot


Representation of Mobile Phone and MP3 Player Assignment

Added on -2019-09-18

| 2 pages
| 1076 words

Trusted by 2+ million users,
1000+ happy students everyday

AssignmentAimThe aim of this assignment is to create a class to represent a gadget, together with two subclasses torepresent a mobile phone and an MP3 player respectively. You will also need to write a report aboutyour program. You are advised to study the learning aid on reflective practice, which is linked fromWebLearn. Your report should be no more than 1200 words in length (excluding the table of contents,class diagram and code listing).DeliverablesWhen you are ready to submit your solution, upload your, and files(not any other files from the project) to WebLearn together with your report in Microsoft Word formatand, when you are absolutely sure that you have uploaded the correct files, press the submit button.Program (60 marks)The program should consist of the following classes (with no additional attributes or methods).1)The Gadget class has four attributes, which correspond to the model, the price (in pounds),theweight (in grams), the size (e.g. “71mm x 137mm x 9mm”) respectively. The price is a decimalnumber, the weight is an integer, and the model and the size are strings of text. Each attribute isinitialised in the constructor, by being assigned the value of one of the constructor's four parameters,and each attribute has a corresponding accessor method. A display method will output (suitablyannotated) the model, the price, the weight and the size [20 marks]2)The Mobile class is a subclass of the Gadget class and has just one attribute, which correspondstothe (whole) number of minutes of calling credit remaining. The attribute is initialised in theconstructor by being assigned the value of one of the constructor's five parameters and it has acorresponding accessor method. The other parameters of the constructor represent the model the price,the weight and the size of the mobile phone and these four values are passed to the constructor of theGadget class.The Mobile class has a method so that the user of the mobile can add (via a parameter) calling credit tothe amount that they currently have. If the amount of credit provided by the user is greater than zerothen this amount is added to the amount of credit stored in the mobile. Otherwise, a message isdisplayed prompting the user to enter a positive amount.There is also a method to represent the user making a phone call. The user needs to provide the phonenumber and the duration of the call in minutes. If there is enough credit then a message giving thephone number and duration is displayed and the remaining calling credit is reduced by the number ofminutes that the call lasted. Otherwise, a message informing the user that there is insufficient credit tomake the call is displayed.A method to display the details of the mobile is required. It must have the same signature as the displaymethod in the Gadget class. It will call the method in the Gadget class to display the model, the price,

Found this document preview useful?

You are reading a preview
Upload your documents to download
Become a Desklib member to get accesss

Students who viewed this