Use Netbeans to run the following decorator pattern code. Provide screenshot to prove that the code runs successfully. Design a UML class diagram to model the program and fully explain the class diagram. SpaceshipDetails.java: public interface SpaceshipDetails {void name(String name);void size(String size);void passengerCabin(int load, int unload);void laserGun(int c);void rangeFinder(int d);void hyperDriver(int dist);} EbonHawk.java: public class EbonHawk implements SpaceshipDetails {@Overridepublic void name(String name) {System.out.println("The name of the ship is: " + name);}@Overridepublic void size(String size) {System.out.println("The size of the ship Ebon Hawk is: " + size);}@Overridepublic void passengerCabin(int load, int unload) {System.out.println("Number of passengers to be loaded: " + load);System.out.println("Number of passengers to be unloaded: " + unload);}@Overridepublic void laserGun(int c) {if (c == 1) {System.out.println("The spaceship has a gun");}else {System.out.println("The spaceship does not contain a laser gun");}}@Overridepublic void rangeFinder(int d) {System.out.println("The distance of the next object: " + d);}@Overridepublic void hyperDriver(int dist) {System.out.println("The distance to the next satr: " + dist);}} Spaceship.java: import java.util.*; public class Spaceship {public static void main(String[] args) {SpaceshipDetails o = new EbonHawk();String name;int c;String size;int load, unload;int d;int distance;Scanner s = new Scanner(System.in);System.out.println("Enter the name of the spaceship: ");name = s.nextLine();System.out.println("Enter the size of the spaceship: ");size = s.next();System.out.println("Enter the number of passengers boarding and getting off "+ "of spaceship: ");load = s.nextInt();unload = s.nextInt();System.out.println("Enter 1 if spaceship has a gun, 0 otherwise: ");c = s.nextInt();System.out.println("Enter the distance of the nearest object (in light years): ");d = s.nextInt();System.out.println("Enter the distance of the star to which jump to (in light year): ");distance = s.nextInt();o.name(name);o.size(size);o.passengerCabin(load, unload);o.laserGun(c);o.rangeFinder(d);o.hyperDriver(distance);s.close();}}

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Use Netbeans to run the following decorator pattern code. Provide screenshot to prove that the code runs successfully.

Design a UML class diagram to model the program and fully explain the class diagram.

SpaceshipDetails.java:

public interface SpaceshipDetails {
void name(String name);
void size(String size);
void passengerCabin(int load, int unload);
void laserGun(int c);
void rangeFinder(int d);
void hyperDriver(int dist);
}

EbonHawk.java:

public class EbonHawk implements SpaceshipDetails {
@Override
public void name(String name) {
System.out.println("The name of the ship is: " + name);
}
@Override
public void size(String size) {
System.out.println("The size of the ship Ebon Hawk is: " + size);
}
@Override
public void passengerCabin(int load, int unload) {
System.out.println("Number of passengers to be loaded: " + load);
System.out.println("Number of passengers to be unloaded: " + unload);
}
@Override
public void laserGun(int c) {
if (c == 1) {
System.out.println("The spaceship has a gun");
}
else {
System.out.println("The spaceship does not contain a laser gun");
}
}
@Override
public void rangeFinder(int d) {
System.out.println("The distance of the next object: " + d);
}
@Override
public void hyperDriver(int dist) {
System.out.println("The distance to the next satr: " + dist);
}
}

Spaceship.java:

import java.util.*;

public class Spaceship {
public static void main(String[] args) {
SpaceshipDetails o = new EbonHawk();

String name;
int c;
String size;
int load, unload;
int d;
int distance;
Scanner s = new Scanner(System.in);

System.out.println("Enter the name of the spaceship: ");
name = s.nextLine();
System.out.println("Enter the size of the spaceship: ");
size = s.next();
System.out.println("Enter the number of passengers boarding and getting off "
+ "of spaceship: ");
load = s.nextInt();
unload = s.nextInt();
System.out.println("Enter 1 if spaceship has a gun, 0 otherwise: ");
c = s.nextInt();
System.out.println("Enter the distance of the nearest object (in light years): ");
d = s.nextInt();
System.out.println("Enter the distance of the star to which jump to (in light year): ");
distance = s.nextInt();

o.name(name);
o.size(size);
o.passengerCabin(load, unload);
o.laserGun(c);
o.rangeFinder(d);
o.hyperDriver(distance);

s.close();
}
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 7 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education