Write Java codes for the diagram below.

Client.java
public class Client {
public static void main(String[] args) {
MobileFactory ldfactory = new
LondonMobileFactory();
SpiceMobile mobile =
ldfactory.produceMobile("SpicePlus");
MobileFactory ldfactory2 = new
LondonMobileFactory();
SpiceMobile mobile2 =
ldfactory2.produceMobile("SpiceBolt");
MobileFactory nyFactory = new
NYMobileFactory();
SpiceMobile mobile3 =
nyFactory.produceMobile("SpiceFire");
MobileFactory nyFactory2 = new
NYMobileFactory();
SpiceMobile mobile4 =
nyFactory2.produceMobile("SpiceBolt");
}
}
LondonMobileFactory.java
public class LondonMobileFactory extends MobileFactory {
@Override
public SpiceMobile constructMobile(String model) {
SpiceMobile mobile = null;
if (model == "SpicePlus"){
mobile = new
SpicePlus();
mobile.setPrice(300);
} else if (model ==
"SpiceBolt"){
mobile = new
SpiceBolt();
mobile.setPrice(400);
}
return mobile;
}
}
MobileFactory.java
public abstract class MobileFactory {
public abstract SpiceMobile constructMobile(String model);
/**
* Defines the process to product mobile. This
implementation should'nt be
* be changed by clients
*
* @param model
* @return SpiceMobile
*/
public SpiceMobile produceMobile(String model) {
SpiceMobile mobile = constructMobile(model);
mobile.makeMobile();
return mobile;
}
}
SpicePlus.java
public class SpicePlus extends SpiceMobile {
@Override
public void prepare() {
System.out.println("Preparing Spice
Plus");
}
@Override
public void bundle() {
System.out.println("Bundling Spice
Plus");
}
@Override
public void label() {
System.out.println("Adding label to
Spice Plus");
}
}
NYMobileFactory.java
public class NYMobileFactory extends MobileFactory {
@Override
public SpiceMobile constructMobile(String model)
{
SpiceMobile mobile = null;
if (model == "SpiceFire"){
mobile = new
SpicePlus();
mobile.setPrice(300);
} else if (model ==
"SpiceBolt"){
mobile = new
SpiceBolt();
mobile.setPrice(400);
}
return mobile;
}
}
SpiceBolt.java
public class SpiceBolt extends SpiceMobile {
@Override
public void prepare() {
System.out.println("Preparing Spice
Bolt");
}
@Override
public void bundle() {
System.out.println("Bundling Spice
Bolt");
}
@Override
public void label() {
System.out.println("Adding label to
Spice Bolt");
}
}
![Problems @ Javadoc 다 Declaration 모 Console X <terminated> Client [Java Application] C:\Program FilesJavarel8.0_201\bin javaw.](http://img.homeworklib.com/images/88be0678-a4fc-49ca-8a86-e2aff2e01435.png?x-oss-process=image/resize,w_560)
Write Java codes for the diagram below. G SpicePlus SpicePlus() o prepare0:void o bundleO:void o label):void C SpiceMobile GSpiceFire o price: double MobileFactory C Client SpiceMobile(0 ..getPrice()...
Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double +setPrice(double): void +toString(): String The class has two attributes, title and price, and get/set methods for the two attributes. The first constructor doesn’t have a parameter. It assigns “” to title and 0.0 to price; The second constructor uses passed-in parameters to initialize the two attributes. The toString() method returns values for the two attributes. Notation: - means private, and + means public. 1....
This code is in java. Create a Java class that has the private double data of length, width, and price. Create the gets and sets methods for the variables. Create a No-Arg constructor and a constructor that accepts all three values. At the end of the class add a main method that accepts variables from the user as input to represent the length and width of a room in feet and the price of carpeting per square foot in dollars...
Write an equals method for the Shirt class provided below. Two shirts are logically equivalent if they have the same size, color, and price. public class Shirt { private Size size; private String color; private double price; enum Size { SMALL, MEDIUM, LARGE } public Shirt(Size size, String color, double price) { this.size = size; this.color = color; this.price = price; } public Size getSize() { return size; } public String getColor() { return color; } public double getPrice() {...
in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "RetailItem" class which simulates the sale of a retail item. It should have a constructor that accepts a "RetailItem" object as an argument. The constructor should also accept an integer that represents the quantity of items being purchased. Your class should have these methods: getSubtotal: returns the subtotal of the sale, which is quantity times price....
USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds data about an item in a retail store. The class should have the following member variables: description: A string that holds a brief description of the item. unitsOnHand: An int that holds thw number of units currently in inventory. price: A double that holds that item's retail price. Write the following functions: -appropriate mutator functions -appropriate accessor functions - a default constructor that sets:...
22. Fill in the codes that creates a Java GUI application that contains a label and a button. The label reads "Click the button to change the background color." When the button is clicked, the background is changed to a red color. The program produces the following output. Point 7 22.1 package javaapplication 179; import javax.swing": import java.ant": import java.awt.exst. public class ColorChange extends JFrame / not allowed to change JLabel label - new JLabel("Click the button to change the...
I've written this program in C++ to compare 2 pizzas using classes and it works fine. I need to convert it to java using both buffered reader and scanner and can't get either to work. //C++ driver class for Pizza program #include <iostream> #include <string> #include <algorithm> #include <iomanip> using std::cout; using std::cin; using std::string; using std::endl; using std::transform; using std::setprecision; using std::ios; using std::setiosflags; #include "Pizza.h" int main() { char response = 'Y'; while (response == 'Y')...
Please help me with my JAVA programming Exercise. a. The Talk-A-Lot Cell Phone Company provides phone services for its customers. Create an abstract class named PhoneCall that includes a String field for a phone number and a double field for the price of the call. Also include a constructor that requires a phone number parameter and that sets the price to 0.0. Include a set method for the price. Also include three abstract get methods—one that returns the phone number,...
Use the Java codes below (Checking Account and Checking Account Demo), and work on these problems. You have to do both of your java codes based on the two provided Java codes. Create one method for depositing and one for withdrawing. The deposit method should have one parameter to indicate the amount to be deposited. You must make sure the amount to be deposited is positive. The withdraw method should have one parameter to indicate the amount to be withdrawn...
In java Se8 i am trying to write a program convert temperature
between celsius, fahrenheit and kelvin, but i am stuck at how to
return the proper result without chage the frame, and I cnould not
figure out how to use those three settemp method.
import java. uti1. Arrays public class Temperature different scale names/ public static Stringll scales -Celsius", "Fahrenheit", "Kelvin private double temperature private char scale; public Temperature (double temp temp 273. 15; this. scale-C if (temp <-273....