Question
I would like help making UML diagrams for the following code : import java.util.*; abstract class SpaceShip{ int numEngines; String name; abstract void ShowSpeed(); }
I would like help making UML diagrams for the following code :
import java.util.*;
abstract class SpaceShip{
int numEngines; String name; abstract void ShowSpeed(); }
class ScoutShip extends SpaceShip{ ScoutShip(){
this.numEngines = 1; this.name = "Scout"; } ScoutShip(int numEngines){ this.numEngines = numEngines; this.name = "Scout"; } public void ShowSpeed(){ int speed = numEngines*2; System.out.printf("%s ship can fly at speed %d warp factor ",this.name,speed); } } class ExplorerShip extends SpaceShip{
ExplorerShip(){ this.numEngines = 2; this.name = "Explorer"; } ExplorerShip(int numEngines){ this.numEngines = numEngines; this.name = "Explorer"; } public void ShowSpeed(){ int speed = numEngines*2; System.out.printf("%s ship can fly at speed %d warp factor ",this.name,speed); } } class TestShip { public static void main(String[] args) {
ScoutShip scoutship = new ScoutShip(); ExplorerShip explorership = new ExplorerShip(3); scoutship.ShowSpeed(); explorership.ShowSpeed(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started