Answer to Question #197436 in Java | JSP | JSF for Syed kaif ali

Question #197436

Write a java Program considering the following scenario.


•Mobile is an Object that contains basic functionalities including Calling & Receiving a call & Messaging. The Mobile has certain features including Processor, internal memory, single or dual SIM, weight. The IMEI number is only used for identifying the device.


•There can be different mobiles like Samsung, iPhone or Nokia which have their own features along with the basic functionality of a mobile phone.


•In case of Samsung, the Android version, Camera Specs and playing FM Radio, capturing photos.


•iPhone may have an ios version, Music Player, Camera.


•Any of these mobile phones can be used to make a call or send a text message.


1
Expert's answer
2021-05-23T14:38:54-0400
import java.util.InputMismatchException;
import java.util.Scanner;


abstract class Mobile {
	private String processor;
	private int internalMemory;
	private boolean isDualSIM;
	private double weight;
	private int MEINumber;


	/**
	 * Constructor
	 */
	public Mobile() {
	}


	/**
	 * Constructor
	 * 
	 * @param processor
	 * @param internalMemory
	 * @param isDualSIM
	 * @param weight
	 * @param MEINumber
	 */
	public Mobile(String processor, int internalMemory, boolean isDualSIM, double weight, int MEINumber) {
		this.processor = processor;
		this.internalMemory = internalMemory;
		this.isDualSIM = isDualSIM;
		this.weight = weight;
		this.MEINumber = MEINumber;
	}


	/**
	 * Make call
	 */
	public void makeCall() {
		System.out.println("Is calling ...");
	}


	/**
	 * Send message
	 * 
	 * @param message
	 */
	public void sendTextMessage(String message) {
		System.out.println("The message '" + message + " has been sent.");
	}


	/**
	 * @return the processor
	 */
	public String getProcessor() {
		return processor;
	}


	/**
	 * @param processor the processor to set
	 */
	public void setProcessor(String processor) {
		this.processor = processor;
	}


	/**
	 * @return the internalMemory
	 */
	public int getInternalMemory() {
		return internalMemory;
	}


	/**
	 * @param internalMemory the internalMemory to set
	 */
	public void setInternalMemory(int internalMemory) {
		this.internalMemory = internalMemory;
	}


	/**
	 * @return the isDualSIM
	 */
	public boolean isDualSIM() {
		return isDualSIM;
	}


	/**
	 * @param isDualSIM the isDualSIM to set
	 */
	public void setDualSIM(boolean isDualSIM) {
		this.isDualSIM = isDualSIM;
	}


	/**
	 * @return the weight
	 */
	public double getWeight() {
		return weight;
	}


	/**
	 * @param weight the weight to set
	 */
	public void setWeight(double weight) {
		this.weight = weight;
	}


	/**
	 * @return the mEINumber
	 */
	public int getMEINumber() {
		return MEINumber;
	}


	/**
	 * @param mEINumber the mEINumber to set
	 */
	public void setMEINumber(int mEINumber) {
		MEINumber = mEINumber;
	}
}


class Samsung extends Mobile {
	private String androidVersion;
	private String cameraSpecs;
	private boolean isPlayingFMRadio;
	private boolean isCapturingPhoto;


	/**
	 * Constructor
	 * 
	 * @param processor
	 * @param internalMemory
	 * @param isDualSIM
	 * @param weight
	 * @param MEINumber
	 * @param androidVersion
	 * @param cameraSpecs
	 * @param isPlayingFMRadio
	 * @param isCapturingPhoto
	 */
	public Samsung(String processor, int internalMemory, boolean isDualSIM, double weight, int MEINumber,
			String androidVersion, String cameraSpecs, boolean isPlayingFMRadio, boolean isCapturingPhoto) {
		super(processor, internalMemory, isDualSIM, weight, MEINumber);
		this.androidVersion = androidVersion;
		this.cameraSpecs = cameraSpecs;
		this.isPlayingFMRadio = isPlayingFMRadio;
		this.isCapturingPhoto = isCapturingPhoto;
	}


	/**
	 * @return the androidVersion
	 */
	public String getAndroidVersion() {
		return androidVersion;
	}


	/**
	 * @param androidVersion the androidVersion to set
	 */
	public void setAndroidVersion(String androidVersion) {
		this.androidVersion = androidVersion;
	}


	/**
	 * @return the cameraSpecs
	 */
	public String getCameraSpecs() {
		return cameraSpecs;
	}


	/**
	 * @param cameraSpecs the cameraSpecs to set
	 */
	public void setCameraSpecs(String cameraSpecs) {
		this.cameraSpecs = cameraSpecs;
	}


	/**
	 * @return the isPlayingFMRadio
	 */
	public boolean isPlayingFMRadio() {
		return isPlayingFMRadio;
	}


	/**
	 * @param isPlayingFMRadio the isPlayingFMRadio to set
	 */
	public void setPlayingFMRadio(boolean isPlayingFMRadio) {
		this.isPlayingFMRadio = isPlayingFMRadio;
	}


	/**
	 * @return the isCapturingPhoto
	 */
	public boolean isCapturingPhoto() {
		return isCapturingPhoto;
	}


	/**
	 * @param isCapturingPhoto the isCapturingPhoto to set
	 */
	public void setCapturingPhoto(boolean isCapturingPhoto) {
		this.isCapturingPhoto = isCapturingPhoto;
	}
}


class iPhone extends Mobile {
	private String iosVersion;
	private String musicPlayer;
	private String camera;


	/**
	 * Constructor
	 * 
	 * @param processor
	 * @param internalMemory
	 * @param isDualSIM
	 * @param weight
	 * @param MEINumber
	 * @param iosVersion
	 * @param musicPlayer
	 * @param camera
	 */
	public iPhone(String processor, int internalMemory, boolean isDualSIM, double weight, int MEINumber,
			String iosVersion, String musicPlayer, String camera) {
		super(processor, internalMemory, isDualSIM, weight, MEINumber);
		this.iosVersion = iosVersion;
		this.musicPlayer = musicPlayer;
		this.camera = camera;
	}


	/**
	 * @return the iosVersion
	 */
	public String getIosVersion() {
		return iosVersion;
	}


	/**
	 * @param iosVersion the iosVersion to set
	 */
	public void setIosVersion(String iosVersion) {
		this.iosVersion = iosVersion;
	}


	/**
	 * @return the musicPlayer
	 */
	public String getMusicPlayer() {
		return musicPlayer;
	}


	/**
	 * @param musicPlayer the musicPlayer to set
	 */
	public void setMusicPlayer(String musicPlayer) {
		this.musicPlayer = musicPlayer;
	}


	/**
	 * @return the camera
	 */
	public String getCamera() {
		return camera;
	}


	/**
	 * @param camera the camera to set
	 */
	public void setCamera(String camera) {
		this.camera = camera;
	}


}


class Nokia extends Mobile {
	private boolean hasBluetooth;


	/**
	 * Constructor
	 * 
	 * @param processor
	 * @param internalMemory
	 * @param isDualSIM
	 * @param weight
	 * @param MEINumber
	 * @param hasBluetooth
	 */
	public Nokia(String processor, int internalMemory, boolean isDualSIM, double weight, int MEINumber,
			boolean hasBluetooth) {
		super(processor, internalMemory, isDualSIM, weight, MEINumber);
		this.hasBluetooth = hasBluetooth;
	}


	/**
	 * @return the hasBluetooth
	 */
	public boolean isHasBluetooth() {
		return hasBluetooth;
	}


	/**
	 * @param hasBluetooth the hasBluetooth to set
	 */
	public void setHasBluetooth(boolean hasBluetooth) {
		this.hasBluetooth = hasBluetooth;
	}
}


public class Q197436 {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Samsung samsung =new Samsung("Processor I5", 64, true,150, 4565, "Android version 8.0", "Camera specs", true,true);
		samsung.sendTextMessage("samsung Test message");
		samsung.makeCall();
		iPhone iPhone=new iPhone("Processor I4", 128, false, 100, 1111, "Ios version 6.1", "music Player", "Camera 5.0");
		iPhone.sendTextMessage("iPhone Test message");
		iPhone.makeCall();
		Nokia nokia=new Nokia("Processor 2",36, true, 500,2222, false);
		
		nokia.sendTextMessage("nokia Test message");
		nokia.makeCall();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS