- Joined
- Jul 6, 2006
- Messages
- 666 (0.10/day)
- Location
- England, UK
Processor | AMD Athlon 3800+ X2 |
---|---|
Motherboard | ASUS A8N-SLI SE |
Cooling | 2 Exhaust fans |
Memory | 2x512MB DDR400 RAM |
Video Card(s) | Connect3D ATI Radeon X1900XT 512MB |
Storage | 80GB Maxtor DiamondMax |
Display(s) | Packard bell 17" CRT |
Case | Stock |
Power Supply | 580W Hiper Type-R |
So ive been asked to create a program with classes and arrays and have been given some lines of code to use in it, the problem is ive been told the code sets up an array gets the next available location to store data but i like to know what my code does line by line without having to copy and paste code thats just been given to me, any help will be greatly appreciated
// setup array
static public Hardware[] NewInitArray(int num)
{
Hardware[] arrhardware = new Hardware[num];
for (int i = 0; i < num; i++)
{
arrhardware = new Hardware();
}
return arrhardware;
}
// get the available location to store the next data
static private int getAvailableLocation(Hardware[] arrhardware)
{
int location=0;
for (int x = 0; x < arrhardware.Length; x++)
{
if (arrhardware[x].ID == 0)
{
location = x;
break;
}
}
return location;
}
// setup array
static public Hardware[] NewInitArray(int num)
{
Hardware[] arrhardware = new Hardware[num];
for (int i = 0; i < num; i++)
{
arrhardware = new Hardware();
}
return arrhardware;
}
// get the available location to store the next data
static private int getAvailableLocation(Hardware[] arrhardware)
{
int location=0;
for (int x = 0; x < arrhardware.Length; x++)
{
if (arrhardware[x].ID == 0)
{
location = x;
break;
}
}
return location;
}