C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 10-22-2009, 07:45 AM   #1
Registered User
 
Join Date: Oct 2008
Posts: 53
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..

Quote:
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
MyRedz is offline   Reply With Quote
Old 10-22-2009, 08:05 AM   #2
l'Anziano
 
DavidP's Avatar
 
Join Date: Aug 2001
Posts: 2,630
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.
__________________
My Website

"Circular logic is good because it is."

Last edited by DavidP; 10-22-2009 at 08:09 AM.
DavidP is offline   Reply With Quote
Old 10-22-2009, 08:08 AM   #3
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,861
Why do you think string[N*] inbox means anything at all?
tabstop is online now   Reply With Quote
Old 10-22-2009, 08:08 AM   #4
Registered User
 
Join Date: Oct 2009
Location: While(1)
Posts: 368
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
RockyMarrone is offline   Reply With Quote
Old 10-22-2009, 08:30 AM   #5
Registered User
 
Join Date: Oct 2008
Posts: 53
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
Quote:
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++..
MyRedz is offline   Reply With Quote
Old 10-22-2009, 08:36 AM   #6
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,861
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?
tabstop is online now   Reply With Quote
Old 10-22-2009, 08:41 AM   #7
Registered User
 
Join Date: Oct 2008
Posts: 53
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?
MyRedz is offline   Reply With Quote
Old 10-22-2009, 08:49 AM   #8
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,861
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.)
tabstop is online now   Reply With Quote
Old 10-22-2009, 11:38 AM   #9
Registered User
 
Join Date: Oct 2008
Posts: 53
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
MyRedz is offline   Reply With Quote
Old 10-22-2009, 11:43 AM   #10
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,861
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.)
tabstop is online now   Reply With Quote
Old 10-22-2009, 12:40 PM   #11
Registered User
 
Join Date: Oct 2008
Posts: 53
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?
Quote:
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?
MyRedz is offline   Reply With Quote
Old 10-22-2009, 12:45 PM   #12
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,861
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.
tabstop is online now   Reply With Quote
Old 10-22-2009, 04:30 PM   #13
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 5,034
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?
Sebastiani is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ coding idea Bnorman C++ Programming 15 10-22-2009 09:14 AM
An idea that's out of my reach of knowledge Akkernight Tech Board 12 04-08-2009 09:35 PM
The chicken and the egg problem... trying to learn coding but having trouble starting mothergoose729 Tech Board 9 03-20-2009 05:22 PM
Before Coding cyberCLoWn C++ Programming 16 12-15-2003 02:26 AM
Inheritance vs Composition Panopticon C++ Programming 11 01-20-2003 04:41 AM


All times are GMT -6. The time now is 07:54 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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