Question: Need help with the following assignment: Objective Learn how Inheritance and Polymorphism works in Java. Instructions Following classes are present in object-oriented software store:IOpenSourceSoftware InterfaceHas

Need help with the following assignment: Objective

Learn how Inheritance and Polymorphism works in Java.

Instructions

Following classes are present in object-oriented software store:IOpenSourceSoftware InterfaceHas methods

getDeveloperCount

getPopularityScore

ICommercialSoftware InterfaceHas methods

getFeatureCount

getPrice

AbstractLinuxSoftware Abstract Class

Has method runOnAndroid

Has method - getLinuxDescription

AbstractWindowsSoftware Abstract Class

Has method runOnSurface

Has method - getWindowsDescription

MSExcel

PremiumMSExcel

ApacheSpark

LightApacheSpark

Identify all the variables and methods required for different types of softwares and use them in your Java classes. If all required variables and methods are not included, MARKS will be deducted.

Use following inheritance hierarchy.

MSExcel implements ICommercialSoftware and extends AbstractWindowsSoftware

MSExcel

getPrice method returns price multiplying feature with 5

ApacheSpark implements contracts defined in IOpenSourceSoftware and extends AbstractLinuxSoftware

getPopularityScore returns some hard coded integer

Write a specialized PremiumExcel class with following behaviors

Inherits MSExcel

getPrice method returns price multiplying feature with 10

Write a specialized LightApacheSpark class with following behaviors

Inherits ApacheSpark

Has twice the popularityScore as ApacheSpark

getLinuxDescription() of LightApacheSpark class should return (Identify variables and methods required using the following snippet):

Software Name: Light Apache Spark

Popularity Score: 200

Developer Count: 20

Time Stamp:

getWindowsDescription() of PremiumMSExcel class should return (Identify variables and methods required using the following snippet):

Software Name: Premium MSExcel

Feature Count: 10

Price: 100

Time Stamp:

Any changes to a base class should get reflected accordingly. (Example: Change in price for MSExcel changes the price of PremiumMSExcel).

Create TestSoftware.java file to test your code and put appropriate testing code for each object. Files: OpenSourceSoftware.java

/**

*

*/

package softwarestore;

/**

* @author chokshi

*

*/

public interface IOpenSourceSoftware {

int getDeveloperCount();

int getPopularityScore();

} CommercialSoftware.java

/**

*

*/

package softwarestore;

/**

* @author chokshi

*

*/

public interface ICommercialSoftware {

int getFeatureCount();

double getPrice();

}

AbstractLinuxSoftware.java

/**

*

*/

package softwarestore;

/**

* @author chokshi

*

*/

public abstract class AbstractLinuxSoftware implements

IOpenSourceSoftware{

private int developerCount;

private int popularityScore;

public void setDeveloperCount(int developerCount) {

this.developerCount = developerCount;

}

public void setPopularityScore(int popularityScore) {

this.popularityScore = popularityScore;

}

@Override

public int getDeveloperCount() {

// TODO Auto-generated method stub

return 0;

}

@Override

public int getPopularityScore() {

// TODO Auto-generated method stub

return 0;

}

}

AbstractWindowsSoftware.java

/**

*

*/

package softwarestore;

/**

* @author chokshi

*

*/

public abstract class AbstractWindowsSoftware implements

ICommercialSoftware {

private int featureCount;

/**

* @param featureCount the featureCount to set

*/

public void setFeatureCount(int featureCount) {

this.featureCount = featureCount;

}

/* (non-Javadoc)

* @see softwarestore.ICommercialSoftware#getFeatureCount()

*/

@Override

public int getFeatureCount() {

return featureCount;

}

/* (non-Javadoc)

* @see softwarestore.ICommercialSoftware#getPrice()

*/

@Override

public double getPrice() {

// TODO Auto-generated method stub

return featureCount * 20;

}

} MsExcel.java

/**

*

*/

package softwarestore;

/**

* @author chokshi

*

*/

public class MSExcel extends AbstractWindowsSoftware implements

ICommercialSoftware{

public MSExcel() {

this.setFeatureCount(300);

}

/* (non-Javadoc)

* @see softwarestore.AbstractWindowsSoftware#getPrice()

*/

@Override

public double getPrice() {

// TODO Auto-generated method stub

return this.getFeatureCount()*5;

}

} PremiumExcel.java

/**

*

*/

package softwarestore;

/**

* @author chokshi

*

*/

public class PremiumExcel extends MSExcel implements ICommercialSoftware {

/**

*

*/

public PremiumExcel() {

// TODO Auto-generated constructor stub

this.setFeatureCount(600);

}

/* (non-Javadoc)

* @see softwarestore.ICommercialSoftware#getPrice()

*/

@Override

public double getPrice() {

//

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!