/// Need help figuring out how to create thee classes, objects and destination f
ID: 3785091 • Letter: #
Question
/// Need help figuring out how to create thee classes, objects and destination for the Ships that I'm working with. I havent coded in more than a year, any help would be great.
We wish to simulate the command and control of a US Navy Aircraft Carrier Battle Group consisting of:
1 Aircraft Carrier
1 Guided Missile Cruiser
1 DDG – Lamps
1 Frigate – Lamps
1 DDG – Non-Lamps
Resupply ship
1 Submarine
All will be derived from a base class ship
Private member data: designation string
Supply state (on a scale 0 to 100)
Supply Use Rate dependent upon speed
Derived objects will be either
Submarine
Surface
All surface ships (types a-f) will have their specific private member data
Type a: list of squadrons
Type f: resupply occurs at 13 knots at a constant distance of 200 yards
ACBG movement will be achieved by assigning each surface vessel a sector (a relative bearing and a range +- delta) relative to the guide (Aircraft carrier). Commands are then given to the Aircraft Carrier and all other ships adjust automatically according to their sector
Submarines do not resupply via type f vessels
Submarines are not assigned a sector
Explanation / Answer
TestCommand.java
class Aircraft {
public void aircaft_checking() {
System.out.println("...............");
}
public void aircaft_status() {
System.out.println("...............");
}
public void aircaft_fired() {
System.out.println(",..........");
}
}
class Missile {
public void missle_check( ) {
System.out.println("...............");
}
public void missle_fire( ) {
System.out.println("...........");
}
}
class Frgate_lamp {
public void turnOn( ) {
System.out.println("..............");
}
public void turnOff( ) {
System.out.println("..........");
}
class DDG_lamp {
public void turnOn( ) {
System.out.println("..............");
}
public void turnOff( ) {
System.out.println("..........");
}
class DDG_nonlamp {
public void turnOn( ) {
System.out.println("..............");
}
public void turnOff( ) {
System.out.println("..........");
}
class Switch {
private Command UpCommand, DownCommand;
public Switch( Command Up, Command Down) {
UpCommand = Up; // concrete Command registers itself with the invoker
DownCommand = Down;
}
void flipUp( ) { // invoker calls back concrete Command, which executes the Command on the receiver
UpCommand . execute ( ) ;
}
void flipDown( ) {
DownCommand . execute ( );
}
}
class Aircraftcommand implements Command {
private Aircraftc myAircarft;
public Aircraftcommand( Aircraftc A) {
myAircarft = A;
}
public void execute( ) {
myAircarft . turnOn( );
}
}
class CruiserCommand implements Command {
private Cr c;
public Cr(Cr c) {
c= c
}
public void execute( ) {
c . turnon( );
}
}
class DGGOnCommand implements Command {
private Lamp mylamp;
public FanOnCommand ( Lamp l) {
mylamp = l;
}
public void execute( ) {
mylamp. start( );
}
}
....
public class TestCommand {
public static void main(String[] args) {
Aircraft a = new Aircraft();
Missile m = new Missile();
DDG_lamp d = new DDG_lamp();
DDG_nonlamp dd = new DDG_nonlamp();
........
}
}
Command.java
public interface Command {
public abstract void execute ( );
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.