Project Scenario OraclProduction OraclProduction Ltd are specialists in producin
ID: 3848467 • Letter: P
Question
Project Scenario OraclProduction OraclProduction Ltd are specialists in producing production line manufacturing plan 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 an 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 AudioMobile AM Visual Mobile VMExplanation / Answer
The question is quite long and can not be completed in the 2 hours alloted. Completed steps 1- 16. Please post a separate question to get answers for other parts. Here is the completed code for steps 1-16
AudioPlayer.java
public class AudioPlayer extends Product implements MultimediaControl, Comparable<Item> {
protected String audioSpecification;
protected ItemType mediaType;
public AudioPlayer(String name, String specification)
{
super(name);
audioSpecification = specification;
mediaType = ItemType.AU;
}
@Override
public void play() {
System.out.println("Playing");
}
@Override
public void stop() {
System.out.println("Stopped");
}
@Override
public void previous() {
System.out.println("Previous");
}
@Override
public void next() {
System.out.println("Next");
}
public String toString()
{
String str = super.toString() + " " ;
str += "Audio Specification: " + audioSpecification + " " + "Type: " + mediaType ;
return str;
}
}
AudioPlayerDriver.java
//driver to test AudioPlayer ... step 6
public class AudioPlayerDriver {
public static void main(String[] args) {
AudioPlayer player=new AudioPlayer("myplayer", "myspec");
System.out.println("Created an audio player and calling methods..");
System.out.println(player);
player.play();
player.previous();
player.next();
player.stop();
}
}
Item.java
import java.util.Date;
public interface Item {
public static final String MANUFACTURER = "OracleProduction";
public void setProductionNumber(int prodNumber);
public void setName(String name);
public String getName();
public Date getManufactureDate();
public int getSerialNumber();
}
ItemType.java
public enum ItemType {
AU, //for Audio type
VI, //for Visual type
AM, //for AudioMobile type
VM // for VisualMobile
}
MonitorType.java
public enum MonitorType {
LCD,
LED
}
MediaCollectionDemo.jav
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
//driver to demonstrate the sorting and printing of products steps 13 - 16
public class MediaCollectionDemo {
private static void print(List<Product> list)
{
for(Product p : list)
System.out.println(p +" ");
}
public static void main(String[] args) {
ArrayList<Product> list = new ArrayList<Product>();
list.add(new AudioPlayer("my audio player 3", "audio spec1"));
list.add(new MoviePlayer("my movie player 3"));
list.add(new AudioPlayer("my audio player 1", "audio spec1"));
list.add(new MoviePlayer("my movie player 1", new Screen("1024x768", 70,20), MonitorType.LED));
list.add(new AudioPlayer("my audio player 2", "audio spec1"));
list.add(new MoviePlayer("my movie player 2"));
Collections.sort(list);
print(list);
}
}
MoviePlayer.java
public class MoviePlayer extends Product implements MultimediaControl, Comparable<Item>{
private Screen screen;
private MonitorType montiorType;
public MoviePlayer(String name)
{
super(name);
screen = new Screen("1024x768", 60, 10);
montiorType = MonitorType.LCD;
}
public MoviePlayer(String name, Screen screen, MonitorType type)
{
super(name);
this.screen = screen;
this.montiorType = type;
}
@Override
public void play() {
System.out.println("Playing");
}
@Override
public void stop() {
System.out.println("Stopped");
}
@Override
public void previous() {
System.out.println("Previous");
}
@Override
public void next() {
System.out.println("Next");
}
public String toString()
{
return super.toString() +" " +
screen.toString() + " " +
"Monitor Type: "+montiorType;
}
}
MoviePlayerDriver.jav
//driver to test MoviePlayer ... step 12
public class MoviePlayerDriver {
public static void main(String[] args) {
MoviePlayer player=new MoviePlayer("my movie player");
System.out.println("Created a movie player and calling methods..");
System.out.println(player);
player.play();
player.previous();
player.next();
player.stop();
}
}
MultimediaControl.java
public interface MultimediaControl {
public void play();
public void stop();
public void previous();
public void next();
}
Product.java
import java.util.Date;
public class Product implements Item, Comparable<Item> {
protected int serialNumber;
protected String manufacturer;
protected Date manufacturedOn;
protected String name;
//class variable
private static int currentProductionNumber = 1;
public Product(String name)
{
setName(name);
setProductionNumber(currentProductionNumber);
currentProductionNumber++;
manufacturer = MANUFACTURER;
manufacturedOn = new Date();
}
@Override
public void setProductionNumber(int prodNumber) {
serialNumber = prodNumber;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public Date getManufactureDate() {
return manufacturedOn;
}
@Override
public int getSerialNumber() {
return serialNumber;
}
public String toString()
{
String str = "Manufacturer: " + manufacturer + " ";
str += "Serial Number: " + serialNumber + " ";
str += "Date: " + manufacturedOn + " ";
str += "Name: " + name ;
return str;
}
//for comparing based on names ..step 14
@Override
public int compareTo(Item o) {
return name.compareTo(o.getName());
}
}
Screen.java
public class Screen implements ScreenSpec {
protected String resolution;
protected int refreshrate;
protected int responsetime;
public Screen(String resolution, int refreshrate, int responsetime)
{
this.resolution = resolution;
this.refreshrate = refreshrate;
this.responsetime = responsetime;
}
@Override
public String getResolution() {
return resolution;
}
@Override
public int getRefreshRate() {
return refreshrate;
}
@Override
public int getResponseTime() {
return responsetime;
}
public String toString()
{
return "Resolution: " + resolution + " " +
"Refresh Rate: " + refreshrate + " " +
"Response Time: " + responsetime ;
}
}
ScreenDriver.java
//driver to test Screen class ... step 10
public class ScreenDriver {
public static void main(String[] args) {
Screen scr = new Screen("1024x768", 60, 10);
System.out.println(scr);
}
}
ScreenSpec.java
public interface ScreenSpec {
public String getResolution();
public int getRefreshRate();
public int getResponseTime();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.