- #1
MarcL
- 170
- 2
Java:
class Cellphone {
private String brand;
private long serialNumber;
private double Price;
public Cellphone (String br, long sN, double Pr)
{
brand= br;
serialNumber = sN;
Price = Pr;
}
public Cellphone(Cellphone aCellphone)
{
this(aCellphone.getbrand(), aCellphone.getserialNumber(), aCellphone.getPrice());
}
}
public class ModifyCellPhone {
public static void main (String[] args)
{
Cellphone[][] cellphoneArr = new Cellphone[10] [10];
for (int i=0; i < cellphoneArr.length-1; i++)
{ for (int m=0; m < cellphoneArr[i].length; m++)
{ if (i % 3 == 0)
cellphoneArr[i][m]= new Cellphone("Samsung", 00000001 + (2 * i+1), 500.4 + i);
else if (i % 3 == 1)
cellphoneArr[i][m] = new Cellphone("LG", 0000001 * (2 * i), 500.6 + i);
}
for (int y=9; y<cellphoneArr.length; y++)
{ for (int n=0; n<cellphoneArr[y].length; n++)
{
cellphoneArr[y][n] = new Cellphone(cellphoneArr [7][n]);
}
}
for (int p = 0; p < cellphoneArr.length; p++) {
// Loop and display sub-arrays.
for (int x = 0; x < cellphoneArr[p].length; x++) {
System.out.print(cellphoneArr[p][x] + " ");
}
System.out.println();
} }
}
}
Thanks for the help :)