Challenge

Project 1

1.

package Project_1;

import java.util.Scanner;

	public class Store {

				@SuppressWarnings("null")
				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 choice=sc.nextInt();

				String typeofuser;

				if (choice ==1)
				{

				  typeofuser= "customer";

				Customer current = new Customer();

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

				current.setUserid(sc.nextLine()); 
				
				System.out.println("what is your Password");

				current.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 productide =sc.nextLine();

				Product[] cartProducts = new Product[50];

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

				cartProducts[0]=a11products[i];


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

					if (allproducts[1].getProductid()==productid)
						
						cartProducts[0]=allproducts[1];

				}
				
					Product [] 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().getListofProducts(); 
					
					for (int i=0; i<cartproducts.length; i++) {

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

					else if (choice==3) {

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

					}
				
					else if (choice==4) {
						
					
						break;
					}
				
					else {
						
					
					
					System.out.println("Invalid.try gain!");

				}
				}
				}
					else 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.