i am building a program like a Shop that have products and have the options of sell them with price and everything .. i wanted to make a options that will allow me to add new Products to the array from the program the its self for doing that i need to increase my array length . and i kind of stuck know , ty for all your help !!
Proudact MilkProd = new Proudact("Milk", 5.55, 50, 10, 0);
Proudact ChessProd = new Proudact("Chess", 4.35, 50, 10, 1);
Proudact AppleProd = new Proudact("Apple", 1.25, 50, 10, 2);
Proudact WotermelonProd = new Proudact("Wotermelon", 6.21, 50, 10, 3);
Proudact [] MyArray = {MilkProd,ChessProd,AppleProd,WotermelonProd};
NewProd(MyArray);
public static void NewProd(Proudact[] MyArray){
Scanner scan = new Scanner(System.in);
for (int i = 0; i < 1; i++) {
MyArray[length] = MyArray[MyArray.length+1];
System.out.println("Enter Proudact Name : ");
String Name = scan.next();
System.out.println("Enter Proudact Price : ");
int price = scan.nextInt();
System.out.println("Enter Proudact Stuck : ");
int Stuck = scan.nextInt();
System.out.println("Enter Proudact MinStuck");
int minStuck = scan.nextInt();
System.out.println("Enter Proudact Id :");
int id = scan.nextInt();
Proudact NewProudact = new Proudact(Name,price,Stuck,minStuck, id);
MyArray[MyArray.length]=NewProudact;
}
}