My coding idea about inheritance for phones

This is a discussion on My coding idea about inheritance for phones within the C++ Programming forums, part of the General Programming Boards category; well here i am just starting to do some coding about handphone to smartphone object..it's an inheritance project but not ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    61

    My coding idea about inheritance for phones

    well here i am just starting to do some coding about handphone to smartphone object..it's an inheritance project but not mine..
    so i would like to share here about the errors and others.
    any help is appreciated...
    now my uml diagram i want to transfer to handwritten coding.so..

    Handphone
    -phoneNumber:string
    -message: string
    -credit:double
    -sms_rate:double
    -inbox:string[N*]
    -object_counter:int
    +<<constructor>> Handphone(no:string, cr:double, rate:double)
    +smsEdit():void
    +smsRead():void
    +operator>>(recipient:Handphone&):void
    +getCredit():double
    +getObjCounter():int
    +operator+(topUp:double): Handphone



    Smartphone
    -mms_message:image
    -mms_inbox:image[N]
    +operator>>(:Smartphone):void
    +mmsRead():void
    +mmsEdit():void
    Fig. 2 Detail UML diagrams

    here's my work...any comments ideas or something..i think it's ok..
    Code:
    class Handphone
    {
    private:
    
    string phoneNumber;
    string message;
    
    double credit;
    
    string inbox[N*];
    
    int object_counter;
    
    
    
    public:
    
    Handphone ( string no, double cr,double rate)
    
    void smsEdit();
    
    void smsRead();
    
    
    }
    
    
    Class Smartphone : public Handphone
    {
    private:
    
    image mms_message;
    image mms_inbox[N];
    public:
    
    void operator>>(Smartphone &s);
    
    void mmsRead();
    
    void mmsEdit();
    
    
    
    
    
    }

    can anyone explain what is string[N*] inbox; and image[N] mms_inbox;
    what is the data type like?? why does it have a bracket?like[*] and [] the initial i suppose it's a pointer thing.
    Last edited by MyRedz; 10-22-2009 at 11:34 AM. Reason: correction of errors

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    Well I assume it's a declaration of an array, but it's all wrong. In fact, there's a pretty blatant mix of Java/C#/C++ in this code.

    The way that those classes and arrays are declared is more of the Java/C# way of doing things.

    This code won't compile in any of the 3 languages.
    Last edited by DavidP; 10-22-2009 at 08:09 AM.
    My Website

    "Circular logic is good because it is."

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Why do you think string[N*] inbox means anything at all?

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    i think in your code which is not pasted you will be having N as #define N with some value

    and thats why image[N] mms_inbox will become an array of image

  5. #5
    Registered User
    Join Date
    Oct 2008
    Posts
    61
    wow...no wonder even myself can't do the uml diagram to code properly..
    it is a mix of 3 languages...
    so your ideas...
    how to make it compilable in the end?this is sure tricky but i just have to try it!
    is my brief coding part from uml ok?
    string[N*] inbox means it is a declaration of inbox size if i am not wrong in a array of N pointer is it?
    well for N is just the box size in here
    N*: inbox size (i.e., the number of sms that can be stored, e.g. 10)
    well i don't see anything for N to be defined..maybe start with 0?
    for
    inbox:string[N*]
    mms_inbox:image[N]
    where can i learn more about mirror image?it isn't found in c++..

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So that means you need to pick a language. I don't think any of us particularly care which language you pick, so you should pick the one you're most comfortable with.

    The * doesn't seem to be meaningful from the language sense; the description makes it sound as though it is a parameter, as opposed to a member variable or something, so perhaps whoever wrote your UML is using * in that way.

    Why do you want to know something about mirror image?

  7. #7
    Registered User
    Join Date
    Oct 2008
    Posts
    61
    ok..* is clear a bit to me..thanks...
    mirror image is something new to me.
    can you show some examples..
    well the language i choose is c++..
    so my initial coding from uml is it correct?

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by MyRedz View Post
    ok..* is clear a bit to me..thanks...
    mirror image is something new to me.
    You can look it up in the dictionary if you want. I'm not aware of a more technical meaning for it, so I don't really know why you're asking about it.
    Quote Originally Posted by MyRedz View Post
    well the language i choose is c++..
    so my initial coding from uml is it correct?
    In that case, no, as your array declarations should follow C++ rules instead. Also, C++ does not allow spaces in variable names (so no "object counter"). You didn't include all the items in your original list in your code. (The "void" in front of your operator>> confused me at first, but that's what your original diagram said so I guess that's okay.)

  9. #9
    Registered User
    Join Date
    Oct 2008
    Posts
    61
    ok.i corrected it..
    string inbox[N*];

    int object_counter;

    image mms_inbox[N];

    so this are the faults is it?
    is this ok?i want to proceed to making the descriptions for each class

  10. #10
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    So string inbox[N*] still doesn't make any sense. If you want an array of N strings, then just do that. (I suppose it's possible you want an array of pointers-to-strings, but it seems unlikely to me somehow.)

  11. #11
    Registered User
    Join Date
    Oct 2008
    Posts
    61
    well i know it's unlikely but then in the uml it says inbox:string[N*]
    and it's usage is N*: inbox size (i.e., the number of sms that can be stored, e.g. 10)..
    well it's usage is for the main purpose of the project that is.
    inheritance from handphone to smartphone
    which means from text message to picture message or mms ones.
    can i proceed to the descriptions?
    Description for class Handphone
    1. Constructor initializes the phoneNumber (default value 012345), credit (default value 50) and sms_rate (default value 2.5). It also increment the object_counter each time an object is created.
    2. smsEdit() allows us to edit sms text freely up to 160 characters. After completing edit, the composed sms can be stored in the phone memory as message before being sent to the recipient.
    3. smsRead()reads received messages from the inbox.
    4. Operator>>()allows us to send sms message to intended recipient.However, here we can only specify the recipient by the object name, rather than the phone number. (It can be done but quite complicated. You are welcome to challenge it for extra marks!)
    5. getCredit() checks the balance of the credit.
    6. getObjCounter()checks the number of existing object.
    7. operator+() tops up the credit with specified amount.

    Class Smartphone
    1. operator>>() allows us to send mms (text image) message to intended recipient. However, here we can only specify the recipient by the object name, rather than the phone number. (It can be done but quite complicated. You are welcome to challenge it for extra marks!). Please create your own interesting and innovative text image.

    |---------------------------
    |<<<<<<<>>>>>>>
    |-----------------------
    |*** )| | (***
    |** )| | (**
    | * )| | (**





    Fig. 3. Sample text image

    2. mmsRead()displays mms message (text image)
    3. mmsEdit()loads text image from file.
    where do i start first?

  12. #12
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by MyRedz View Post
    well i know it's unlikely but then in the uml it says inbox:string[N*]
    and it's usage is N*: inbox size (i.e., the number of sms that can be stored, e.g. 10)..
    well it's usage is for the main purpose of the project that is.
    So did you read what you just typed? Your UML document is using N* as a variable. You can't use * in a variable name in C++, so don't call it N*. And just to (re)iterate: That constant, whatever you end up calling it, must be defined as a constant prior to this class
    being defined for what you have to work.
    Quote Originally Posted by MyRedz View Post
    inheritance from handphone to smartphone
    which means from text message to picture message or mms ones.
    can i proceed to the descriptions?


    where do i start first?
    You can start anywhere you like.

  13. #13
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,652
    Quote Originally Posted by MyRedz View Post
    where do i start first?
    This may seem counterintuitive, but, believe it or not, the best way to start is to actually learn the language that you plan to use. Sounds crazy, right?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ coding idea
    By Bnorman in forum C++ Programming
    Replies: 15
    Last Post: 10-22-2009, 09:14 AM
  2. An idea that's out of my reach of knowledge
    By Akkernight in forum Tech Board
    Replies: 12
    Last Post: 04-08-2009, 09:35 PM
  3. Replies: 9
    Last Post: 03-20-2009, 05:22 PM
  4. Before Coding
    By cyberCLoWn in forum C++ Programming
    Replies: 16
    Last Post: 12-15-2003, 01:26 AM
  5. Inheritance vs Composition
    By Panopticon in forum C++ Programming
    Replies: 11
    Last Post: 01-20-2003, 03:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21