Challenge

Project 1

package Challenge5;

import java.util.Scanner;

public class Store {

public static void main(String[] args) {
System.out.println("Welcome to Ecommerce store");

System.out.println("Which one are you? 1.customer 2.seller 3.admin");

Scanner sc=new Scanner(System.in);

int customer,seller,admin,choice;
customer=sc.nextInt();

String typeofuser; if (choice ==1) {

typeofuser="customer";

customer current =new customer();

System.out.println("what is your userid");

current.setUserid (sc.nextLine());

System.out.println("whatis your Password");

String setPassword = sc.nextLine();

if( current.verifyuser() == true) {

System.out.println("user verified!");

while (true) {

System.out.println("Do you want to 1.view Product 2. view cart 3. Contact us 4.Exit");

choice=sc.nextInt();

if (choice =1) { Catalogue catalogue = new Catalogue();

Product[] allproducts = catalogue.getListofAllProducts();

for (int i=0; i<allproducts.length; i++) {

System.out.println(allproducts[i].getProductid()+" "+allproducts[i].getProductname ()+" "+allproducts[i].getCos);

System.out.println("Do You want to add Products to cart? Y/N");

sc.nextLine();

String addtocart = sc.nextLine();

String anothername = addtocart;

if (addtocart.equals("Y"))

System.out.println("Input the product Id you want to add to cart");

String productid=sc.nextLine(); Product[] cart Products = new Product [50];

for (int i=0; i<allproducts.length; i++) { if (allproducts [i].getProductid ()=productid)

cart Products [0]=allproducts[i];
for (int i=0; i<allproducts.length; i++) { if (allproducts [i].getProductid() ==productid) cartProducts [0]=allproducts[i];

}

Product 1 cartproducts;

Cart cart= new Cart(); current.setCart (cart);

System.out.println("The Product is sucessfully added to the cart");

else if (choice ==2) {

Product[] cartproducts = current.getCart().getListof Products();

for (int i=0; i<cartproducts.length; i++) { Object[] cartproducts;
System.out.println(cartproducts[i].getProductid ()+" "+cartproducts[i].getProductname ()+" "+cartproducts[i].get);

}

if (choice ==3) {

System.out.println("To contact us email us [email protected]");

int choice;
if (choice ==4) {

break;

}

else {

System.out.println("Invalid.try gain!");

String typeofuser;
if (choice ==2)

typeofuser="Seller";

else if (choice ==3)

typeofuser="Admin";

else

System.out.println("Invalid Try again");
}}}}

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.