I can create an new array "supermarket_backround" and also add the username, and the tempproduct but when I go to the method get_info_productions_list() I will recognise the the array with the name but not the tempproducts, so their will be the error [Ljava.lang.String;@3d075dc0. It would be kind to help me.
import java.util.Scanner;
public class Mennu {
static Scanner sc = new Scanner(System.in);
static boolean stop = true;
static customer[] database = new customer[100];
static supermarket_backround[] products = new supermarket_backround[100];
static int accounts = 0;
static int products_list = 0;
public static void main(String[] args) {
while(stop==true) {
Menu();
}
}
private static void Menu() {
String temp = input();
if(temp.equals("add")) {
add_account();
}else if(temp.equals("product")) {
add_products_list();
}else if(temp.equals("Info")) {
get_info_productions_list();
}
}
private static String input() {
String temp = "";
while(temp=="") {
Scanner Input = new Scanner(System.in);
temp = Input.next();
}
return temp;
}
public static void add_products_list() {
System.out.println("Name of the list.");
String tempname_of_the_list;
tempname_of_the_list = sc.next();
System.out.println("Now you can add 10 products to your supermarket.");
String[] tempproducts = new String[10];
for(int i = 0;i<tempproducts.length;i++) {
tempproducts[i] = sc.next();
System.out.println("This is your " + i + " product.");
}
products[products_list] = new supermarket_backround(tempproducts, tempname_of_the_list);
System.out.println("List was created.");
accounts++;
}
public static void get_info_productions_list() {
System.out.println("Please enter the name of the list.");
String tempname;
tempname = sc.next();
for (int i = 0; i < accounts; i++) {
if(products[i].name_of_the_list.equals(tempname)) {
System.out.println("This are your products.");
System.out.println(products[i].products);
}else {
System.out.println("Account was not found.");
}
}
}
}
class supermarket_backround {
String []products = new String[10];
String name_of_the_list;
public supermarket_backround(String[] tempproducts, String tempname_of_the_list) {
products = tempproducts;
name_of_the_list = tempname_of_the_list;
}
public void add_products(String[] tempproducts) {
products = tempproducts;
}
public void remove_products(String[] ptempproducts) {
}
}