Click here to Skip to main content

Design and Architecture

 
Questionrich text editor PinmemberDanielos_s2330-Jan-13 11:03 
AnswerRe: rich text editor PinmemberJosé Amílcar Ferreira Casimiro11-Feb-13 6:37 
QuestionMVVM, EF and TDD tutorials Pinmembercansino17-Jan-13 7:06 
QuestionJava and C# operating on the same data in an ASP-based monitoring web application. PinmembervValkir17-Jan-13 1:18 
AnswerRe: Java and C# operating on the same data in an ASP-based monitoring web application. PinmemberJonathan C Dickinson17-Jan-13 4:05 
Questionindesign cs6 trial - no toolbar PinmemberMember 93448236-Jan-13 13:10 
AnswerRe: indesign cs6 trial - no toolbar PinprotectorPete O'Hanlon17-Jan-13 1:49 
QuestionHow do you design this? : with a better example PinmemberVuNic30-Dec-12 18:57 
There is a huge hybrid battle ship that sail, load cargo, carry ammunition, commandos, & sometimes go down the water like a submarine, and some time camouflager itself based on the surroundings. It does a lot of things, & equally has a lot of properties like, color, size, Housing capacity, firing capabilities. etc.
 

Now, on the ship, there's only one place where I can mount ammunition.
 
I have a set of ammunition. Anti-aircraft guns, fire shells, Launch missiles, etc etc. but all these are "mutually exclusive".
 
If I would like to mount the ship with Anti-aircraft guns, all other ammo go unusable. I can dynamically swap between available ammo.
 
class BattleShip
{
  propert A,B ,.....Z;
 
  void MountAndFire(Ammo ammo_in)
  {
 
//if it's a gun,
	int ammo_in.Fire(numberofrounds:30);  //returns remaining ammo
   
// if it's a missle launcher:
        float  ammo_in.Fire(direction:120, distance:200); // return ammount of heat it generated on the ship

//cluster bomb
        int ammo_in.Fire(Numberofcluster:600, direction:120, Distance:200);// Returns something else

  }
 
};
 

How do you have a generic design to address this? I thought of having a Ammo Interface, and have a Fire() call,
But the parameter for the fire call differ for all the ammo. So I cant' say:
 
interface IAmmo
{
  virtual int Fire();
 
}
 
Missile: IAmmo
{
 int  Fire()
{
} 
} 
 

The simple ordinary way is to check:
void MountAndFire(object ammo_in)
  {
 

//if it's a gun,

        if(ammo_in.GetType==typeof(Antiaircraftgun)
	    {
            AntiAirCraftGun aag = (AntiAirCraftGun) ammo_in;
 
            aag.Fire(30);
        }
 
//Missle
        if(ammo_in.GetType==typeof(Missile)
	    {
            Missle missile = (Missile) ammo_in;
 
            missile.Fire(120,200);   
        }
	    
	
  }
 
You have a better idea for this?

Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

AnswerRe: How do you design this? : with a better example PinmvpChristian Graus30-Dec-12 19:25 
GeneralRe: How do you design this? : with a better example PinmemberVuNic30-Dec-12 19:42 
GeneralRe: How do you design this? : with a better example PinmvpChristian Graus30-Dec-12 19:46 
AnswerRe: How do you design this? : with a better example Pinmemberjschell31-Dec-12 10:10 
AnswerRe: How do you design this? : with a better example PinmemberEddy Vluggen31-Dec-12 18:04 
AnswerRe: How do you design this? : with a better example PinmemberKeld Ølykke16-Jan-13 12:23 
QuestionHow to find the similarity between users in Twitter ? How to design a good and efficient idea? Pinmemberldaneil27-Dec-12 8:26 
AnswerRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? PinprotectorPete O'Hanlon27-Dec-12 8:39 
GeneralRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pinmemberldaneil27-Dec-12 8:50 
AnswerRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pinmemberjschell27-Dec-12 10:21 
GeneralRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pinmemberldaneil28-Dec-12 9:31 
AnswerRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? [modified] PinmemberApril Fans27-Dec-12 16:43 
GeneralRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? Pinmemberldaneil28-Dec-12 9:36 
GeneralRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? [modified] PinmemberApril Fans3-Jan-13 17:46 
AnswerRe: How to find the similarity between users in Twitter ? How to design a good and efficient idea? PinprofessionalMarc Koutzarov30-Aug-14 0:54 
QuestionClient - Server approach Pinmemberbugal21-Dec-12 1:33 
AnswerRe: Client - Server approach Pinmemberjschell22-Dec-12 15:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.150123.1 | Last Updated 23 Jan 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid