473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

IncrementPointer( )

Add the following to class Store.
private int current =0;
public incrementPointer()
// pre: store is not empty
// post: increments current;
// if current is already pointing to the
// last record in the Store then reset it to 0

Please can someone help. We have to increment a class Store as part of an assignment. We have to read & write an array of files so stored to a folder. the first part of the assignment is as above but what does it mean exactly? Store inherits from "Person", "Date" & "Employee" if this makes any sense.What is an increment pointer exactly? Thanks
Mar 5 '07 #1
6 1442
DeMan
1,806 1GB
This is not a site that gives out solutions to homework (but you already know that, with 20 posts)....
Mind you we are more than willing to help if you can clearly specify the exact nature of your problem....

To help you in your problem, we need to know a little more information (what a Store is? I assume it is a class you have already created, but what is it's' function so far....etc)
We would also like to know how you might approach the problem, whether you have had any ideas and specifically where it is that you're stuck.

I'm sure if you post a little bit you're stuck on, then we can gradually work through the problem (just post again when you hit the next snag)...and hopefully help you to not just complete the assignment, but understand it as well....
Mar 5 '07 #2
r035198x
13,262 8TB
Add the following to class Store.
private int current =0;
public incrementPointer()
// pre: store is not empty
// post: increments current;
// if current is already pointing to the
// last record in the Store then reset it to 0

Please can someone help. We have to increment a class Store as part of an assignment. We have to read & write an array of files so stored to a folder. the first part of the assignment is as above but what does it mean exactly? Store inherits from "Person", "Date" & "Employee" if this makes any sense.What is an increment pointer exactly? Thanks
Not everything here makes sense. You need to explan more clearly your goal, what you have done so far in trying to achieve that goal and where you are finding difficulty.
Mar 5 '07 #3
public class Store
{
private Person list[];
private int count;
private int maxSize;
private int current;


// constructor

public Store(int max)
{
list = new Person[max];
maxSize = max;
count = 0;
current = 0;
}

// transformer



public void add (Person p)
{
// pre p is not null and the store is not full
// post p is added to array
list[count] = p;
count ++;
}

// accessors

public boolean isFull()
{
// post returns true if no more room in store
return count == maxSize;
}


public int getCount()
{
// returns the number of elements currently in store
return count;

}

public Person elementAt(int index)
{
///pre 0 <= index < getCount
return list[index];
}

public boolean isIn(Person p)
{
// returns true if p is stored
boolean found = false;
for (int index = 0; index < count; index ++)
if (p.equals(list[index]))
found = true;
return found;
}

//output method

public void displayAll()
{
// displays the contents of store on screen
for (int index = 0; index < count; index ++)
System.out.println(list[index]);

}




}
Here is infamous store from an earlier assignment.
Requirements You are required to produce a system that allows a user to do the following:
a) Employee record using a form displayed on the screen; note: an employee record includes all the data items inherited from Person. b) save the entered record to a store;
c) retrieve and display records from the store; each time this
option is selected the next record is displayed; when the end of the store is reached the first record is displayed;
d) save a store to a file;
e) retrieve a store from a file.
Person & Employee are similar classes which are inherited from. What we don't understand is what the increment pointer is trying to do & how. We appreciate it is a method of one sort of another, but does it require an operator or boolean or what?
Mar 5 '07 #4
r035198x
13,262 8TB
public class Store
{
private Person list[];
private int count;
private int maxSize;
private int current;


// constructor

public Store(int max)
{
list = new Person[max];
maxSize = max;
count = 0;
current = 0;
}

// transformer



public void add (Person p)
{
// pre p is not null and the store is not full
// post p is added to array
list[count] = p;
count ++;
}

// accessors

public boolean isFull()
{
// post returns true if no more room in store
return count == maxSize;
}


public int getCount()
{
// returns the number of elements currently in store
return count;

}

public Person elementAt(int index)
{
///pre 0 <= index < getCount
return list[index];
}

public boolean isIn(Person p)
{
// returns true if p is stored
boolean found = false;
for (int index = 0; index < count; index ++)
if (p.equals(list[index]))
found = true;
return found;
}

//output method

public void displayAll()
{
// displays the contents of store on screen
for (int index = 0; index < count; index ++)
System.out.println(list[index]);

}




}
Here is infamous store from an earlier assignment.
Requirements You are required to produce a system that allows a user to do the following:
a) Employee record using a form displayed on the screen; note: an employee record includes all the data items inherited from Person. b) save the entered record to a store;
c) retrieve and display records from the store; each time this
option is selected the next record is displayed; when the end of the store is reached the first record is displayed;
d) save a store to a file;
e) retrieve a store from a file.
Person & Employee are similar classes which are inherited from. What we don't understand is what the increment pointer is trying to do & how. We appreciate it is a method of one sort of another, but does it require an operator or boolean or what?
1.)You do not have to post your homework code
2.)If you really have to post code please do so using code tags
3.)The store class should have a pointer (in this case int will do) that points to the currently displayed item. It should have signature
Expand|Select|Wrap|Line Numbers
  1.  public void incrementPointer() 
Mar 5 '07 #5
YEH I'D ALREADY GOT THAT...It was kind of you and all that, but what is the incrementPointer trying to do? Is it pointing to a particular name in the store?There is another part to the question. Shall I send it?
Mar 5 '07 #6
r035198x
13,262 8TB
YEH I'D ALREADY GOT THAT...It was kind of you and all that, but what is the incrementPointer trying to do? Is it pointing to a particular name in the store?There is another part to the question. Shall I send it?
incrementPointer increments the value of the variable current (which points to the currently displayed person the Store). You need to make sure it caters for all scenarios. If you have completed all the other parts you can go ahead to the next part but make sure you try it first before you post. Post only if you really feel you are suck with it.
Mar 5 '07 #7

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.