I hope someone can help.
I am trying to write a Java program that will pass an Int-type, String-type and an object into an array that will loop 100 times, filling it with the items in parentheses. I have no clue how to accomplish this as I am brand new to Java and to programming in general. The last method is the one I need help filling. Please help!!
public class Locator
{
// array sizes (and limits)
private final static int STORE_LIMIT = 100;
private final static int POSTAL_ZONE_LIM IT = 100;
// instance variables
Store [] storeArray;
PostalZone [] postalZoneArray ;
private int nextStore;
private int nextPostalZone;
/**
* Constructor for objects of class Locator.
*/
public Locator()
{
storeArray = new Store[STORE_LIMIT];
postalZoneArray = new PostalZone[POSTAL_ZONE_LIM IT];
}
/**
* addStore - add a store to the array of stores.
*
* @param inputStoreNumbe r int Store number to add
* @param inputDescriptio n String Store description to add
* @param inputLocation String Location of store
*
* @return int index of added store, -1 if unable to
* add (array already full)
*/
public int addStore(int inputStoreNumbe r, String inputDescriptio n,
Location inputLocation)
{
}
TIA,
Dave
1 2339 D_C 293
Contributor
First, thanks for actually having a nice concise question, although you could have used [ code] and [/code ] tags (with no spaces between the brackets) to preserve whitespace.
I don't see where Store is defined, I'm assuming something like this: - class Store
-
{
-
private int num;
-
private String desc;
-
private String loc;
-
-
Store(int number, String description, String location)
-
{
-
num = number;
-
desc = description;
-
loc = location;
-
}
-
...
-
}
- /**
-
* addStore - add a store to the array of stores.
-
*
-
* @param inputStoreNumber int Store number to add
-
* @param inputDescription String Store description to add
-
* @param inputLocation String Location of store
-
*
-
* @return int index of added store, -1 if unable to
-
* add (array already full)
-
*/
-
-
public int addStore(int inputStoreNumber, String inputDescription, Location inputLocation)
-
{
-
if(nextStoreIndex == STORE_LIMIT)
-
return -1;
-
storeArray[nextStoreIndex++] = new Store(inputStoreNumber, inputDescription, inputLocation);
-
return (nextStoreIndex-1);
-
}
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: ABC |
last post by:
I am not a javascript guru or anything so I was wondering if someone
could tell me what the code below is doing. Is it creating a
multidimensional array? Would it be better to create an object?
function addKey(commentKey, codeHexa, gotoPage, funcToLoad)
{
aKey = new Array();
aKey = commentKey;
aKey = codeHexa;
|
by: don |
last post by:
My question is, do C++ array of objects hold the objects or just the
pointers to the objects..... I know Java arrays only hold pointers to
objects, but I seem to remember that C++ arrays hold the actual object.....
please set me straight......
|
by: Gent |
last post by:
I have two questions which are very similar:
Is it possible to return an object in C++. Below is part of my code
for reference however I am more concerned about the concept. It seems
like the function below is returning a pointer to pointers who are
GUID. I am trying to write a wrapper to use in my VB code and what I
would prefer to do is be able to return an array of GUID. I remember
(not sure) that the concept of arrays does not really...
|
by: Ben |
last post by:
I have a program which is using a lot of memory.
At the moment I store a lot of pointers to objects in std::vector.
(millions of them)
I have three questions:
1) Lets say the average Vector is of size 2. How much memory can I
save by storing my pointers in c++ arrays, rather than vectors.
|
by: Mingus Tsai |
last post by:
Hello- please help with unpickling problem:
I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows
XPhome system.
My problem is with using cPickle to deserialize my pickled arrays of
datetime.datetime instances. The following is the code I have written:
import cPickle, datetime
import Numeric
| |
by: Gomaw Beoyr |
last post by:
Hello
Is there any explanation why Microsoft chose to implement
arrays as objects allocated on the heap instead of structs
allocated on the stack?
For "mathematical stuff", one normally wishes to avoid
unnecessary garbage collection, but that is exactly what's
going to happen if a lot of arrays, matrixes etc are allocated
on the heap.
|
by: Jack |
last post by:
Hi,
Is there a general solution for the following problem:
I have an array of instances of class B. Class B is publicly derived from
class A. Then I have a class named Buffer that generally takes care of
allocating and deallocating arrays. Class Buffer knows only that the objects
contained in its internal array are derived from class A but not that they
are exactly of type B, so Buffer has a member variable of type A* that
points at...
|
by: Sheldon |
last post by:
Hi,
I have the following loop that I think can be written to run faster in
Numeric. I am currently using Numeric.
range_va =
main.xsize= 600
main.ysize= 600
#msgva is an (600x600) Numeric array with mutiple occurrences of the
values in range_va
#sat_id is an (600x600) Numeric array with values ranging from -2 to 2
|
by: Mike Kent |
last post by:
The APL 2007 conference, sponsored by ACM SIGAPL,
has as its principal theme "Arrays and Objects" and,
appropriately, is co-located with OOPSLA 2007, in
Montreal this October.
APL 2007 starts with a tutorial day on Sunday, October 21, followed by a
two-day program on Monday and Tuesday, October 22 and 23.
APLers are welcome to attend OOPSLA program events on Monday and Tuesday
|
by: Dr Dav |
last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation,
previously written in IDL, in C with the goal reducing runtime. As you
may imagine, my C programming skills are quite poor but I am learning.
My problem is this. I had sucessfully written a C code that worked
( with considerable speedup over the IDL version ) using an array size
of 100x100. However, I am working towards making the array size closer
to 300x300. Since I had...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |