Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save EqualizerTiger-bit/dbd2ff8c37ba7a755d6b5cd42c354e9e to your computer and use it in GitHub Desktop.
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.
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