Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project Scenario OraclProduction OraclProduction Ltd are specialists in producin

ID: 3848438 • Letter: P

Question

Project Scenario OraclProduction OraclProduction Ltd are specialists in producing production line manufacturing plants They could be asked to create a production plant for any type of product ranging from a simple packaging system to a variety of electronic devices. Recently they have been asked to create a production line for multimedia devices which include music and movie players. They wish to employee you to design a template in Java for creating and recording all future production line items. For this particular production facility you will only implement a concrete class for music and movie players. Your task is to create a flexible structure that could be used in any production line. This structure would then allow easy modification to handle different products. Step 1 Create an interface called Item that will force all classes to implement the following functions. A constant called manufacturer that would be set to "OracleProduction". A method setProductionNumber that would have one integer parameter A method setName that would have one String parameter A method getName that would return a String A method getManufactureDate that would return a Date A method getSerialNumber that would return a int Step 2 All items will have a pre-set type. Currently there are 4 types. Create an enum called ItemType that will store the following information Type Code Audio AU Visual VI Audio Mobile AM Visual Mobile VM Step 3

Explanation / Answer

Step 1 )

An interface is a reference type in Java. It is similar to class. It is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. Writing an interface is similar to writing a class. But a class describes the attributes and behaviors of an object. And an interface contains behaviors that a class implements.

NOTE : IN the question we are asked to have a constant fileld in the interface. But its not a good practice. this kind of pattern is called " Constant Interface Antipattern"

//Below is the interaface

public interface Item
{
public constant string manufacturer = "Oracle Prodution" ;
public void setProdutionNumber(int value) ;
public void setName(stirng name ) ;
public String getName() ;
public Date getManufacturedDate() ;
public int getSerielNumber() ;
  
}
//Step 2
//define the enum as folows
public enum ItemType {AU,VI,AM,VM }
//step 3 : define a abstract class
abstract class Product implements Item
{
int serialNumber ;
string manufacturer ;
Date manufacturedOn ;
String name ;
static int currentProductionNumber ; //this is the class variable .To define a class variable we use keyword static
  
public void setProdutionNumber(int value)
{
serialNumber = currentProductionNuber ;
}
public void setName(stirng name )
{

this.name = name ;
}
public String getName()
{
return this.name ;
}

public Date getManufacturedDate()
{
return manufacturedOn ;
}
public int getSerielNumber()
{
  
return serialNumber ;

}

public Product(String name)
{
setName(name) ;
setProdutionNumber(currentProductionNuber ) ;
currentProductionNumber++ ;
manufacturedOn = new Date() ;
  
}
  
public String toString()
{ DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");

//to convert Date to String, use format method of SimpleDateFormat class.
String strDate = dateFormat.format(manufacturedOn);

String out = "Manufacturer : Oracle Productio " + "SeiralNumber :" + serialNumber.toString()+" " + "Date :"+strDate " " + "Name :" +name ;
}
}

//step 4
public interface MultimediaControl
{
public void Play() ;
public void Stop() ;
public void Previous() ;
public void Next() ;
}