Notices
The Basement Non-Honda/Acura discussion. Content should be tasteful and "primetime" safe.

Computer People v.ADTHelp

Thread Tools
 
Old 09-07-2006, 08:35 AM
  #1  
M@rshy
٩(̾●̮̮̃̾•̃̾)۶
Thread Starter
 
M@rshy's Avatar
 
Join Date: Aug 2004
Posts: 21,807
Likes: 0
Received 0 Likes on 0 Posts
Default Computer People v.ADTHelp

:thinking: Okay, so we were taught how to do ADT definitions, yet I'm still totally confused by it. My book doesn't describe it at all and my teacher is out of the office for today.
Does anyone here know how to describe it for me? I'm really confused on what to do.
In my homework it says:
Code:
// value of arr[2] is fetched from the array and multiplied by 3
x = arr[2] *3;
arr[2] = 3;             //3 is stored as the new value of arr[2]
So they just basically told you two ways to assign 3 to arr[2].

Then:
Give an ADT representation of an array that described two versions of the [] operator, corresponding to the fetch and store operations. Give examples using array index notation arr[i] rather than the formal function prototype for the [] operator.
Thats where I'm confused about even what they want and how to put it into ADT..
Anyone have any idea about what I'm talking about or that could help me out a little?
Old 09-07-2006, 08:54 AM
  #2  
clickwir
Floppy Death! noES!!!
 
clickwir's Avatar
 
Join Date: Oct 2002
Location: Scranton, PA
Posts: 21,218
Likes: 0
Received 0 Likes on 0 Posts
Default

Didn't they just say to use the arr[i]?

So answer would be: arr[2] = 3

no?
Old 09-07-2006, 09:08 AM
  #3  
M@rshy
٩(̾●̮̮̃̾•̃̾)۶
Thread Starter
 
M@rshy's Avatar
 
Join Date: Aug 2004
Posts: 21,807
Likes: 0
Received 0 Likes on 0 Posts
Default

But I need to put it into ADT definition. Heres an example:
Code:
ADT time24
DATA:
        hour is an integer (0-23) storing the current hour
        minute is an integer (0-60) storing the current minute
OPERATIONS:
        getHour()      returns current hour
        getMinute()   returns current minute
        addTime(m)   incrememnt time by m minutes
                          pre: m >= 0
                          Post: current time is increased

But I'm not sure what operations there would be and all that bs.




All times are GMT -8. The time now is 03:46 AM.