Created
August 15, 2024 18:26
-
-
Save EqualizerTiger-bit/dbd2ff8c37ba7a755d6b5cd42c354e9e to your computer and use it in GitHub Desktop.
A Class that gives code for how customers can move in a shopping website.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.FileReader; | |
import java.io.FileWriter; | |
import java.io.IOException; | |
import java.util.*; | |
import java.util.stream.Collectors; | |
public class Customer { | |
private String name; | |
public Customer(String name, String storeName) { | |
this.name = name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getName() { | |
return name; | |
} | |
// Search for products based on name, store, or description in Menus | |
public static String searchProduct(String s) { | |
String product = ""; | |
try (BufferedReader br = new BufferedReader(new FileReader("products.csv"))) { | |
String line = br.readLine(); | |
while (line != null) { | |
String[] lineArray = line.split(","); | |
if(lineArray[0].contains(s) || lineArray[3].contains(s) || lineArray[4].contains(s)) { | |
for (int i = 0; i < lineArray.length; i++) { | |
product += lineArray[i]; | |
} | |
} | |
line = br.readLine(); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
return product; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment