Hi yea I\'m screwed for this assignment. If you could help me out that would pul
ID: 3717757 • Letter: H
Question
Hi yea I'm screwed for this assignment. If you could help me out that would pull me through for this class thank you.
All your java files should belong to a package.
All java files should’ve your Name and Net ID at the beginning.
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
Provided files (you may change provided code to handle the assignment requirements)
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: <Current 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: <Current 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.
Total Possible Points: 100
Draw inheritance diagram with Class name, variables and methods that shows the inheritance relationships between the above 8 classes – 10 points(Submit as pdf or jpeg)
Program runs as submitted - 5 points
Design MSExcel Class to meet the requirements as described above – 15 points
Design PremiumMSExcel Class to meet the requirements as described above – 15 points
Design ApacheSpark Class to meet the requirements as described above – 15 points
Design LightApacheSpark Class to meet the requirements as described above – 15 points
Write a TestSoftware Class to invoke the behavior of the specific softwares using their instances as asked below - 25 points divided as below
Created object of MSExcel and print details using getWindowsDescription – 5 points
Created object of PremiumMSExcel and print details using getWindowsDescription – 5 points
Created object of ApacheSpark and print details description using getLinuxDescription – 5 points
Created object of LightApacheSpark and print details using getLinuxDescription – 5 points
Test other public methods – 5 points
----------------------------------------------------------------------------------------------------
IOpenSourceSoftware.java
/**
*
*/
package softwarestore;
/**
* @author chokshi
*
*/
public interface IOpenSourceSoftware {
int getDeveloperCount();
int getPopularityScore();
}
--------------------------------------------------------------------
ICommercialSoftware.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() {
//
}
}
Explanation / Answer
package solution.softwarestore;
public interface ICommercialSoftware {
int getFeatureCount();
double getPrice();
}
//////////////////
package solution.softwarestore;
public interface IOpenSourceSoftware {
int getDeveloperCount();
int getPopularityScore();
}
///////////////////////////////
package solution.softwarestore;
public abstract class AbstractLinuxSoftware implements IOpenSourceSoftware {
private int developerCount;
private int popularityScore;
protected String type;
public abstract String getLinuxDescription();
public void setType(String type) {
this.type = type;
}
public void setDeveloperCount(int developerCount) {
this.developerCount = developerCount;
}
public void setPopularityScore(int popularityScore) {
this.popularityScore = popularityScore;
}
@Override
public int getDeveloperCount() {
return developerCount;
}
@Override
public int getPopularityScore() {
return popularityScore;
}
protected String getType() {
return type;
}
}
//////////////////////////////
package solution.softwarestore;
public abstract class AbstractWindowsSoftware implements ICommercialSoftware {
private int featureCount;
protected String type = "Windows Software";
public void setType(String type){
this.type =type;
}
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;
}
public abstract String getWindowsDescription() ;
public abstract String getType() ;
}
////////////////////////////////////////////
package solution.softwarestore;
import com.sun.jmx.snmp.Timestamp;
public class ApacheSpark extends AbstractLinuxSoftware implements IOpenSourceSoftware{
ApacheSpark(){
super();
setType("ApacheSpark");
setPopularityScore(10);
setDeveloperCount(16);
}
public String getLinuxDescription() {
return "Software Name: "+getType()+", Popularity Score: "+ getPopularityScore()+", Developer Count: "+getDeveloperCount()+" ,Time Stamp: "+new Timestamp();
}
}
//////////////////////////
package solution.softwarestore;
import com.sun.jmx.snmp.Timestamp;
public class LightApacheSpark extends ApacheSpark {
LightApacheSpark(){
super();
setType("LightApacheSpark");
setPopularityScore(10);
setDeveloperCount(20);
}
public String getLinuxDescription() {
return "Software Name: "+getType()+", Popularity Score: "+ getPopularityScore()+", Developer Count: "+getDeveloperCount()+" ,Time Stamp: "+new Timestamp();
}
public int getPopularityScore(){
return super.getPopularityScore()*2;
}
}
/////////////////////////////////////////
package solution.softwarestore;
import com.sun.jmx.snmp.Timestamp;
public class MSExcel extends AbstractWindowsSoftware implements
ICommercialSoftware {
public MSExcel() {
super();
super.setType("MSExcel");
this.setFeatureCount(300);
}
@Override
public double getPrice() {
return this.getFeatureCount() * 5;
}
@Override
public String getWindowsDescription() {
return "Software Name: "+getType()+" ,Feature Count: "+ getFeatureCount() +" ,Price: "+getPrice() +" ,Time Stamp: "+new Timestamp();
}
@Override
public String getType() {
return type;
}
}
///////////////////////////////////
package solution.softwarestore;
import com.sun.jmx.snmp.Timestamp;
public class PremiumExcel extends MSExcel implements ICommercialSoftware {
public PremiumExcel() {
super();
super.setType("PremiumExcel");
this.setFeatureCount(300);
}
@Override
public double getPrice() {
return getFeatureCount()*10;
}
public String getWindowsDescription() {
return "Software Name: "+ getType()+" ,Feature Count: "+getFeatureCount()+" ,Price: "+getPrice()+" ,Time Stamp: "+new Timestamp();
}
}
/////////////////////////////////////////
package solution.softwarestore;
public class TestSoftware {
public static void main(String[] args) {
System.out.println("Software details :");
//Created object of MSExcel and print details using getWindowsDescription
MSExcel msexcelObject = new MSExcel();
System.out.println(msexcelObject.getWindowsDescription());
//Created object of PremiumMSExcel and print details using getWindowsDescription
PremiumExcel pExcelOnject = new PremiumExcel();
System.out.println(pExcelOnject.getWindowsDescription());
//Created object of ApacheSpark and print details description using getLinuxDescription
ApacheSpark aSpark= new ApacheSpark();
System.out.println(aSpark.getLinuxDescription());
//Created object of LightApacheSpark and print details using getLinuxDescription
LightApacheSpark lSpark= new LightApacheSpark();
System.out.println(lSpark.getLinuxDescription());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.