https://www.dropbox.com/s/owm2ja9d02xa16r/class.jpg?dl=0
https://www.dropbox.com/s/1bi6hawvtvix1nn/usecase1.jpg?dl=0
https://www.dropbox.com/s/nxouisah8chp73f/usecase2.jpg?dl=0
Above is my usecase diagram, class diagram, two usecases for the program.
and below is the my program code
Main class
Expand|Select|Wrap|Line Numbers
- package fttconsole;
- import java.util.*;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class FTTConsole {
- static int choice;
- static FoodTruckTracker fd = new FoodTruckTracker();
- public static void main(String[] args) throws NumberFormatException, IOException {
- // Input from the use
- Scanner input = new Scanner(System.in);
- String line;
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- // Exception handling
- try {
- do {
- System.out.println("\t\t\t\t\t\t\t\t\t\t\t FOOD TRUCK REGISTRATION");
- System.out.println("\t\t\t\t\t\t\t\t\t\t\t ========================");
- System.out.println("");
- System.out.println("\t\t\t\t\t\t\t\t\t\t\t 01.SignUP / LogIn");
- System.out.println("\t\t\t\t\t\t\t\t\t\t\t 02.Maintain Food Trucks");
- System.out.println("\t\t\t\t\t\t\t\t\t\t\t 03.View Food Truck Information");
- System.out.println("\t\t\t\t\t\t\t\t\t\t\t 04.Review Food Truck Information");
- System.out.println("\t\t\t\t\t\t\t\t\t\t\t 05.QUIT ");
- // User enter choice
- System.out.print("Enter Your Choice: ");
- line = br.readLine();
- choice = Integer.parseInt(line);
- switch (choice) {
- case 1:
- FoodTruckTracker.SignUp();
- break;
- case 2:
- FoodTruckTracker.RecordFoodTruck();
- case 3:
- //1 FoodTruckTracker.ViewFoodTruckInfo();
- break;
- case 4:
- // System.out.println("THANK YOU!");
- break;
- case 5:
- System.out.println("THANK YOU!");
- break;
- }
- } while (choice != 5);
- // catch and throw an error msg and prompt to enter correctly.
- } catch (NumberFormatException e) {
- System.out.println("Please insert a number 1, 2 OR 3 as a choice.!!!");
- System.out.print("Enter Your Choice: ");
- line = br.readLine();
- choice = Integer.parseInt(line);
- }
- }// end main
- }// end class
Expand|Select|Wrap|Line Numbers
- package fttconsole;
- import java.util.ArrayList;
- import java.util.Iterator;
- public abstract class User {
- // variables
- private String username;
- private String password;
- private String fullName;
- private String email;
- // ArayList of users
- private ArrayList<User> users = new ArrayList<>();
- // no-arg constructor
- public User() {
- }
- // paramatized constructor
- public User(String username, String password, String fullName, String email) {
- this.username = username;
- this.password = password;
- this.fullName = fullName;
- this.email = email;
- }
- // Getters and Setters
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getFullName() {
- return fullName;
- }
- public void setFullName(String fullName) {
- this.fullName = fullName;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public ArrayList<User> getUsers() {
- return users;
- }
- public void setUsers(ArrayList<User> users) {
- this.users = users;
- }
- public void addUser(User userIn) {
- users.add(userIn);
- }
- // Search User By User Name
- public abstract User searchUserByName(String Name);
- // Search User by Password
- public abstract User searchUserPassword(String password) ;
- public boolean equals(FoodTruckOwner obj){
- boolean result=false;
- if (obj instanceof FoodTruckOwner){
- FoodTruckOwner rhs = (FoodTruckOwner)obj;
- if(this.getUsername().equals(rhs.getUsername()))
- result= true;
- else
- result= false;
- }
- return result;
- }
- abstract String getAverageRatings();
- // toString method
- @Override
- public String toString() {
- return "USER NAME : " + username + ", PASSWORD : " + password + ", FULL NAME : " + fullName + ", EMAIL :" + email;
- }
- }
Expand|Select|Wrap|Line Numbers
- package fttconsole;
- import java.util.ArrayList;
- import java.util.Iterator;
- public class Customer extends User {
- private final ArrayList<Customer> customers = new ArrayList<>();
- //no-arg constructor
- public Customer() {
- }
- // paramatized constructor
- public Customer(String username, String password, String fullName, String email) {
- super(username, password, fullName, email);
- }
- // toString method
- @Override
- public Customer searchUserByName(String Name) {
- Iterator<Customer> itr = customers.iterator();
- while (itr.hasNext()) {
- Customer custobj = itr.next();
- if (!custobj.getUsername().equals(Name)) {
- System.out.println("User name don't exist.!!! Pls. Enter a Valid Username!");
- } else {
- return custobj;
- }
- }
- return null;
- }
- @Override
- public void addUser(User customerIn) {
- customers.add((Customer) customerIn);
- }
- @Override
- public Customer searchUserPassword(String password) {
- Iterator<Customer> itr = customers.iterator();
- while (itr.hasNext()) {
- Customer custobj = itr.next();
- if (!custobj.getPassword().equals(password)) {
- System.out.println("Your password is incorrect.!!! Pls. Enter a correct password!");
- } else {
- return custobj;
- }
- }
- return null;
- }
- @Override
- public String toString() {
- return super.toString();
- }
- @Override
- String getAverageRatings() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
- } // end Customer class
Expand|Select|Wrap|Line Numbers
- package fttconsole;
- import java.util.ArrayList;
- import java.util.Iterator;
- public class FoodTruckOwner extends User {
- // variables
- private String licenceNo;
- private ArrayList<FoodTruckOwner> foodtruckowners;
- private ArrayList<FoodTruck> truck_collection = new ArrayList<FoodTruck>() ;
- //no-arg constructor
- public FoodTruckOwner() {
- this.foodtruckowners = new ArrayList<>();
- }
- // pramatized constructor
- public FoodTruckOwner(String username, String password, String fullName, String email, String licenceNo) {
- super(username, password, fullName, email);
- this.foodtruckowners = new ArrayList<>();
- this.licenceNo = licenceNo;
- }
- // Setters and getters
- public String getLicenceNo() {
- return licenceNo;
- }
- public void setLicenceNo(String licenceNo) {
- this.licenceNo = licenceNo;
- }
- public ArrayList<FoodTruckOwner> getFoodtrucksOwners() {
- return foodtruckowners;
- }
- public void setFoodtruckOwners(ArrayList<FoodTruckOwner> foodtruckowners) {
- this.foodtruckowners = foodtruckowners;
- }
- public ArrayList<FoodTruck> getTruck_collection() {
- return truck_collection;
- }
- public void setTruck_collection(ArrayList<FoodTruck> Truck_collection) {
- this.truck_collection = Truck_collection;
- }
- // toString method
- public void addTruck( FoodTruck truckObj){
- this.truck_collection.add(truckObj);
- }
- @Override
- public void addUser(User foodtruckOwnerIn) {
- foodtruckowners.add((FoodTruckOwner) foodtruckOwnerIn);
- }
- @Override
- String getAverageRatings() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
- @Override
- public FoodTruckOwner searchUserByName(String Name) {
- Iterator<FoodTruckOwner> itr = foodtruckowners.iterator();
- while (itr.hasNext()) {
- FoodTruckOwner ownerobj = itr.next();
- if (!ownerobj.getUsername().equals(Name)) {
- System.out.println("You are not a Valid User!!! You must be a FoodTruck Owner"
- + " to Add or Modify!!!");
- } else {
- return ownerobj;
- }
- }
- return null;
- }
- @Override
- public FoodTruckOwner searchUserPassword(String password) {
- Iterator<FoodTruckOwner>itr = foodtruckowners.iterator();
- while (itr.hasNext()) {
- FoodTruckOwner ownerobj = itr.next();
- if (!ownerobj.getPassword().equals(password)) {
- System.out.println("Your password is incorrect.!!! Pls. Enter a correct password!");
- } else {
- return ownerobj;
- }
- }
- return null;
- }
- @Override
- public String toString() {
- return super.toString() + "\t Licence No: " + getLicenceNo();
- }
- }
Expand|Select|Wrap|Line Numbers
- package fttconsole;
- import java.util.ArrayList;
- import java.util.Iterator;
- public class FoodTruck {
- // variables
- private int truckID = 0;
- private String truckName;
- private String location;
- private String foodType;
- private String status;
- // ArrayList of FoodTrucks
- private ArrayList<FoodTruck> foodtrucks = new ArrayList<>();
- private ArrayList<FoodTruckOwner> foodtruckOwner = new ArrayList<>();
- // no-arg constructor
- public FoodTruck() {
- }
- // paramatized constructor
- public FoodTruck(int truckID, String truckName, String location, String foodType, String status) {
- this.truckID = truckID;
- this.truckName = truckName;
- this.location = location;
- this.foodType = foodType;
- this.status = status;
- }
- public int getTruckID() {
- return truckID;
- }
- public void setTruckID(int truckID) {
- this.truckID = truckID;
- }
- public String getTruckName() {
- return truckName;
- }
- public void setTruckName(String truckName) {
- this.truckName = truckName;
- }
- public String getLocation() {
- return location;
- }
- public void setLocation(String location) {
- this.location = location;
- }
- public String getFoodType() {
- return foodType;
- }
- public void setFoodType(String foodType) {
- this.foodType = foodType;
- }
- public String getStatus() {
- return status;
- }
- public void setStatus(String status) {
- this.status = status;
- }
- public ArrayList<FoodTruck> getFoodtrucks() {
- return foodtrucks;
- }
- public void setFoodtrucks(ArrayList<FoodTruck> foodtrucks) {
- this.foodtrucks = foodtrucks;
- }
- public ArrayList<FoodTruckOwner> getFoodtruckOwner() {
- return foodtruckOwner;
- }
- public void setFoodtruckOwner(ArrayList<FoodTruckOwner> foodtruckOwner) {
- this.foodtruckOwner = foodtruckOwner;
- }
- public void addTruck( FoodTruck truckObj){
- this.foodtrucks.add(truckObj);
- }
- // Display all the Truck details by a particular user
- public void displayAllByTruckId(User userIn) {
- Iterator<FoodTruck> itr = foodtrucks.iterator();
- while (itr.hasNext()) {
- FoodTruck truckobj = itr.next();
- if (truckobj.getTruckID() != 0) {
- System.out.println("------------------------------------------------" + "\n"
- + "TRUCK ID : " + truckobj.getTruckID() + "\n"
- + "TRUCK NAME :" + truckobj.getTruckName() + "\n"
- + "FOOD TYPE : " + truckobj.getFoodType() + "\n"
- + "LOCATION : " + truckobj.getLocation() + "\n"
- + "STATUS :" + truckobj.getStatus() + "\n"
- + "------------------------------------------------");
- } else {
- System.out.println("No FoodTrucks added Yet!!!!");
- }
- }
- }
- public void searchTruckByUserId(int truckID) {
- Iterator<FoodTruck> itr = foodtrucks.iterator();
- while (itr.hasNext()) {
- FoodTruck truckobj = itr.next();
- if (truckobj.getTruckID() == truckID) {
- for (int i = 0; i < foodtrucks.size(); i++) {
- System.out.println("Truck ID : " + foodtrucks.get(i).truckID + "\t\t" + "TRUCK NAME : " + foodtrucks.get(i).truckName);
- }
- }
- }
- }
- public FoodTruck searchTruckByTruckId(int truckID) {
- Iterator<FoodTruck> itr = foodtrucks.iterator();
- while (itr.hasNext()) {
- FoodTruck truckobj = itr.next();
- if (truckobj.getTruckID() == (truckID)) {
- return truckobj;
- }
- }
- System.out.println("There is No Truck By that ID..");
- return null;
- }
- @Override
- public String toString() {
- return "FoodTruck{" + "truckID=" + truckID + ", truckName=" + truckName + ", location=" + location + ", foodType=" + foodType + ", status=" + status + ", foodtrucks=" + foodtrucks + ", foodtruckOwner=" + foodtruckOwner + '}';
- }
- }
Expand|Select|Wrap|Line Numbers
- package fttconsole;
- import java.util.*;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class FoodTruckTracker {
- // Array List of users and foodtrucks
- static ArrayList<User> users = new ArrayList<>();
- static ArrayList<FoodTruck> foodtrucks = new ArrayList<>();
- // variables
- private static int truckId = 0;
- private static String location = "";
- private static String status = "";
- // Instance of class User and FoodTruck
- static FoodTruck objFoodTruck = new FoodTruck();
- static User objCustomer = new Customer();
- static User objFoodTruckOwner = new FoodTruckOwner();
- //static User objUser2 = new FoodTruckOwner();
- static Scanner sc = new Scanner(System.in);
- //no-arg constructor
- public FoodTruckTracker() {
- }
- // paramatized constructor
- public FoodTruckTracker(ArrayList<User> users, ArrayList<FoodTruck> foodtrucks, ArrayList<FoodTruckOwner> foodtruckowners) {
- FoodTruckTracker.users = users;
- FoodTruckTracker.foodtrucks = foodtrucks;
- }
- // Getters and Setters
- public ArrayList<User> getUsers() {
- return users;
- }
- public void setUsers(ArrayList<User> users) {
- FoodTruckTracker.users = users;
- }
- public ArrayList<FoodTruck> getFoodtrucks() {
- return foodtrucks;
- }
- public void setFoodtrucks(ArrayList<FoodTruck> foodtrucks) {
- FoodTruckTracker.foodtrucks = foodtrucks;
- }
- // Method SignUp User
- public static void SignUp() {
- System.out.println("\n \t USER SIGN UP ");
- System.out.print("------------------------------------------------\n");
- System.out.print("--> Are You a Customer(C) or Truck Owner(T)? : ");
- String choice = sc.next();
- System.out.println();
- //If the user is a Customer Type
- if (choice.equalsIgnoreCase("C")) {
- sc.nextLine();
- // Enter username
- System.out.print("USER NAME : ");
- String username = sc.nextLine();
- // if user name is greater than 20
- if (username.length() > 20) {
- do { // error msg. Invalid input! until a correct value is entered.
- System.out.println("Invalid Input!! Please Enter Username not greater than 20 character : ");
- username = sc.nextLine();
- } while (username.length() > 20);
- }
- // User enter password
- System.out.print("PASSWORD :");
- String password = sc.nextLine();
- // If password is not valid
- if (!passValid(password)) {
- do { // error msg. Invalid password! until a correct value is entered.
- System.out.println("InValid Input!! Write a password greater than 6 character");
- System.out.print("PASSWORD :");
- password = sc.nextLine();
- } while (!passValid(password));
- }
- // Enter full name
- System.out.println("FULL NAME : ");
- String fullname = sc.nextLine();
- // if full name is greater than 20 character
- if (fullname.length() > 20) {
- do { //error msg. Invalid full name! until a correct value is entered.
- System.out.println("Invalid Input!! Please Enter Fullname not greater than 20 character : ");
- username = sc.nextLine();
- } while (username.length() > 20);
- }
- // Enter user email
- System.out.print("EMAIL : ");
- String email = sc.nextLine();
- // if email is not valid
- if (!emailValid(email)) {
- do { // error msg. Invalid Email.! until a correct value is entered.
- System.out.println("Invalid Input!! Please Enter email in the format java2@gmail.com : ");
- System.out.print("EMAIL :");
- email = sc.next();
- } while (!emailValid(email));
- }
- // new Customer is created
- System.out.println("------------------------------------");
- System.out.println("-->Are You sure You want to Save!! (Y/N)");
- String answer = sc.next();
- if (answer.equalsIgnoreCase("y")) {
- Customer cust = new Customer(username, password, fullname, email);
- objCustomer.addUser(cust);
- System.out.println("Customer added successfully .....");
- System.out.println(cust.toString());
- LogInAndUpdateCust();
- } else {
- System.out.println("Cancelled Information....");
- }
- // Else User is a Food Truck Owner
- } else if (choice.equalsIgnoreCase("T")) {
- // Enter user name
- sc.nextLine();
- System.out.print("USERNAME : ");
- String username = sc.nextLine();
- if (username.length() > 20) {
- do { // If username is not Valid.. error msg. until a correct one is entered.
- System.out.print("Invalid Input!!. Please enter username not greater than 20");
- System.out.println("USERNAME : ");
- username = sc.nextLine();
- } while (username.length() > 20);
- } // Enter password
- System.out.print("PASSWORD :");
- String password = sc.nextLine();
- if (!passValid(password)) {
- do { // password is incorrect error msg. prompt to enter the correct value.
- System.out.print("Not a Valid Password. Pls. Enter a password not less than 6 character!!");
- System.out.println("PASSWORD :");
- password = sc.nextLine();
- } while (!passValid(password));
- }
- // Enter full name
- System.out.print("FULL NAME :");
- String fullname = sc.nextLine();
- if (fullname.length() > 20) {
- do { // error msg. until a valid name is entered.
- System.out.print("Invalid Name. Name should not be more than 20 characters in length!!");
- System.out.println("FULL NAME :");
- fullname = sc.nextLine();
- } while (fullname.length() > 20);
- }
- // User enter email address
- System.out.print("EMAIL : ");
- String email = sc.nextLine();
- if (!emailValid(email)) {
- do { // error msg. until a valid email is entered.
- System.out.println("InValid Email!! Write email in the format java2@gmail.com");
- System.out.print("EMAIL :");
- email = sc.nextLine();
- } while (!emailValid(email));
- } // Enter Licence Number
- System.out.print("ENTER LICENSE NO in the format -> L1111: ");
- String license = sc.nextLine();
- license = license.toUpperCase();
- // If licence in not valid
- if (!isValidLicence(license)) {
- do { // error msg. until a valid licence is entered.
- System.out.println("InValid License!! Write License in the format -> L1111");
- System.out.print("LICENSE :");
- license = sc.nextLine();
- } while (!isValidLicence(license));
- }
- // New Truck Owner is created.
- User ownerIn = new FoodTruckOwner(username,password,fullname,email,license);
- System.out.println("------------------------------------");
- System.out.println("-->Are You sure You want to Save!! (Y/N)");
- String answer = sc.next();
- if (answer.equalsIgnoreCase("Y")) {
- objFoodTruckOwner.addUser(ownerIn); // --------------------------------------------------------------> TruckOwners to a different list
- System.out.println("Truck Owner added successfully .....");
- System.out.println(ownerIn.toString());
- System.out.println();
- LogInAndUpdateOwner();
- } else {
- System.out.println("Cancelled Information....");
- }
- } else {
- System.out.println("Enter either Customer(C) or Truck Owner (T)");
- }
- }
- public static void LogInAndUpdateCust() {
- // User Login to the System Method
- System.out.println();
- System.out.println("------------------------------------------------------------------");
- System.out.println("--> Please LogIn to the System By Entering your Username and Password.");
- System.out.println();
- // Enter username
- System.out.print("Enter your username : ");
- String username = sc.next();
- // user is searched
- User foundUser = objCustomer.searchUserByName(username);
- // if user found
- if (foundUser == null) { // Enter password
- do{
- System.out.print("Enter your username : ");
- username = sc.next();
- foundUser = objCustomer.searchUserByName(username);
- }while(foundUser==null);
- }
- System.out.println("Enter your password :");
- String password = sc.next();
- User foundPass = objCustomer.searchUserPassword(password);
- // if password is correct user LogIned.
- if(foundPass==null){
- do{
- System.out.println("Enter your password : ");
- password = sc.next();
- foundPass = objCustomer.searchUserPassword(password);
- }while(foundPass==null);
- }
- System.out.println("");
- System.out.println("You are Successfully LogIned.!!!!");
- // Option for the user to Modify the logIn details or Not
- System.out.println("--> Do you wants to Modify your LogIn details ??(Y)es OR (N)o :");
- String ans = sc.next();
- //if user wants to modify
- if (ans.equalsIgnoreCase("Y")) {
- // User modify the details
- System.out.print("Full Name :");
- String newfullName = sc.next();
- System.out.print("Email : ");
- String newEmail = sc.next();
- System.out.print("password : ");
- String newPassword = sc.next();
- // user entered details is set and updated.
- foundUser.setUsername(newfullName);
- foundUser.setPassword(newPassword);
- foundUser.setEmail(newEmail);
- System.out.println("---------------------");
- System.out.println("Updated Successfully!!");
- } else { // if user don't want to modify logout.
- System.out.println("You are Logged Out");
- }
- }
- public static void LogInAndUpdateOwner() {
- // User Login to the System Method
- System.out.println();
- System.out.println("------------------------------------------------------------------");
- System.out.println("--> Please LogIn to the System By Entering your Username and Password.");
- System.out.println();
- // Enter username
- System.out.print("Enter your username : ");
- String username = sc.next();
- // user is searched
- User foundUser = objFoodTruckOwner.searchUserByName(username);
- // if user found
- if (foundUser == null) { // Enter password
- do{
- System.out.print("Enter your username : ");
- username = sc.next();
- foundUser = objFoodTruckOwner.searchUserByName(username);
- }while(foundUser==null);
- }
- System.out.println("Enter your password :");
- String password = sc.next();
- User foundPass = objFoodTruckOwner.searchUserPassword(password);
- // if password is correct user LogIned.
- if(foundPass==null){
- do{
- System.out.println("Enter your password : ");
- password = sc.next();
- foundPass = objFoodTruckOwner.searchUserPassword(password);
- }while(foundPass==null);
- }
- System.out.println("");
- System.out.println("You are Successfully LogIned.!!!!");
- // Option for the user to Modify the logIn details or Not
- System.out.println("--> Do you wants to Modify your LogIn details ??(Y)es OR (N)o :");
- String ans = sc.next();
- //if user wants to modify
- if (ans.equalsIgnoreCase("Y")) {
- // User modify the details
- System.out.print("Full Name :");
- String newfullName = sc.next();
- System.out.print("Email : ");
- String newEmail = sc.next();
- System.out.print("password : ");
- String newPassword = sc.next();
- // user entered details is set and updated.
- foundUser.setUsername(newfullName);
- foundUser.setPassword(newPassword);
- foundUser.setEmail(newEmail);
- System.out.println("---------------------");
- System.out.println("Updated Successfully!!");
- } else { // if user don't want to modify logout.
- System.out.println("You are Logged Out");
- }
- }
- // Email Validator
- public static Boolean emailValid(String email) {
- if (email.contains("@") || email.contains(".com")) {
- return true;
- } else {
- return false;
- }
- }
- // Password Validator
- public static Boolean passValid(String pass) {
- if (pass.length() > 6) {
- return true;
- } else {
- return false;
- }
- }
- //Licence Validator
- public static Boolean isValidLicence(String Licence) {
- int lengd = Licence.length();
- //Sé til thess ad bílnúmer getur ekki verid lengra en 5 stafir
- if (lengd > 5) {
- System.out.println("License numbers can not be more then 5 characters");
- }
- Matcher m = Pattern.compile("[A-Z](\\d\\d)\\d\\d").matcher(Licence);
- if (m.find()) {
- return true;
- } else {
- return false;
- }
- }
- // Add Food Truck Method
- public static void RecordFoodTruck() {
- //1. User Login to the System
- // Truck Owner Login to the System Method
- System.out.println();
- System.out.println("------------------------------------------------------------------");
- System.out.println("--> Please LogIn to the System By Entering your Username and Password.");
- System.out.println();
- // Enter username
- System.out.print("Enter your username : ");
- String username = sc.next();
- // user is searched
- User foundUser = objFoodTruckOwner.searchUserByName(username);
- // if user found
- if (foundUser == null) { // Enter password
- do{
- System.out.print("Enter your username : ");
- username = sc.next();
- foundUser = objFoodTruckOwner.searchUserByName(username);
- }while(foundUser==null);
- }
- System.out.println("Enter your password :");
- String password = sc.next();
- User foundPass = objFoodTruckOwner.searchUserPassword(password);
- // if password is correct user LogIned.
- if(foundPass==null){
- do{
- System.out.println("Enter your password : ");
- password = sc.next();
- foundPass = objFoodTruckOwner.searchUserPassword(password);
- }while(foundPass==null);
- }
- System.out.println("");
- System.out.println("You are Successfully LogIned.!!!!");
- System.out.println("*****************************************");
- System.out.println("Full Name : " + foundUser.getFullName());
- System.out.println("Email : " + foundUser.getEmail());
- System.out.println("*****************************************");
- // show the list of foodTrucks belongs to the user if exist
- objFoodTruck.displayAllByTruckId(foundUser); // -------------------------------------------------------- A method to display foodtrucks belonging to
- // to the user only.
- // 2. Add Food Truck Information
- System.out.println();
- System.out.println("---------------------------------------------\n");
- System.out.println("\n \t RECORD FOOD TRUCK INFORMATION ");
- System.out.print("------------------------------------------------\n");
- // Option to Add a Truck or Modify Food Truck.
- System.out.println("Do you want to (A)dd Or (M)odify Food Truck Information ?: ");
- String ans = sc.next();
- // If user wants to Add
- // if user wants to add a truck
- if (ans.equalsIgnoreCase("A")) {
- System.out.print("Truck ID : ");
- // truck Id is generated automatically and incremented as user add more trucks.
- truckId++;
- objFoodTruck.setTruckID(truckId);
- System.out.println(truckId);
- // User enter Truck Name
- System.out.print("Truck Name : ");
- String truckName = sc.next();
- // Truck location automatically set to unknown
- System.out.print("Truck Location :");
- location = "unknown";
- objFoodTruck.setLocation(location);
- System.out.println(location);
- // User enter Food type
- System.out.print("Food Type : ");
- String foodType = sc.next();
- // User status automatically set to unknown
- System.out.print("Status : ");
- status = "unknown";
- objFoodTruck.setLocation(status);
- System.out.println(status);
- // A new Food truck is created
- FoodTruck foodtruck = new FoodTruck(truckId, truckName, location, foodType, status);
- // Food truck added to arraylist
- objFoodTruck.addTruck(foodtruck);// -----------------------------------------------------------Truck to be added to the found user
- System.out.println();
- System.out.println(foodtruck.toString());
- System.out.println();
- System.out.println("Truck Added Successfully.");
- //If user wants to modify the truck information
- } else if (ans.equalsIgnoreCase("M")) {
- //3. Method to Modify Trucks Information
- } else {
- System.out.println("You should Enter (A)dd or (M)odify Only!! ");
- }
- }
- }
My problem is in food Maintain foodtruck.. in the Menu choice.
user login by entering username and password. After login
the user foodtruckowner either add or modify.
When the foodtruckowner(which is a user) login the foodtrucks he has added will be shown. My problem is all
the foodtrucks is showing to the user..
I know this is a simple mistake.. I couln't solve it..
A help is most appreciated...
Thanks