Question: /* * This file is the registration class for the Vehicle Rental System. * */ package model; import java.util.Map; import utility.FileLoader; /** * Represents User



/* * This file is the registration class for the Vehicle Rental System. * */
package model;
import java.util.Map; import utility.FileLoader;
/** * Represents User Sign-in Object. * * Methods of this class throw NullPointerException if required parameters are null. * */
public class Registration {
/** * User Storage File. */ public static final String USERFILE_NAME = "./resources/registeredusers.txt";
/** * The registered user list for signin. */ private final Map
/** * Constructs a sigin/registration system. * * */ public Registration() { myUserList = FileLoader.readItemsFromFile(USERFILE_NAME); }
/** * getter for myUserList. * * @return myUserList */ public Map
/** * display sign-in or registration options. */ public void printSignin() {
// ------------Fill in--------------------// }
/** * Verify Sign-in procedure. * * @param theUsername username for sign-in * @param thePassword password for signin * @return sign-in success */ public boolean login(final String theUsername, final String thePassword) {
// ------------Fill in--------------------// return true; }
/** * Adds a user to the registered user list. * * @param theUser an order to add to this shopping cart * @return true/false returns if registration is successfull */ public boolean register(final User theUser) {
// ------------Fill in--------------------//
return true;
}
/** * Empties the user list. */ public void clear() {
// ------------Fill in--------------------// }
@Override /** * String representation of the object * */ public String toString() {
// ------------Fill in--------------------// return "rentz"; }
}
****************************************************
package model;
/** * RentalMain provides the main method for a simple VehicleRental application. *
*/ public final class RentalMain {
/** * A private constructor, to prevent external instantiation. */ private RentalMain() {
}
/** * Main method for Rentz. * * @param theArgs argument for main method. */ public static void main(final String[] theArgs) { final Registration reg = new Registration(); reg.printSignin(); }
}
**************************************************** package model;
/** * Represents a single user for registration or sign-in. User is an immutable object. * * Constructors and methods of this class throw NullPointerException if required parameters are * null. * */ public final class User {
}
package utility;
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import model.User;
/** * A utility class for the VehicleRental application. *
*/ public final class FileLoader {
/** * spit token. */ public static final String SPLIT_TOKEN = ",";
/** * A private constructor, to prevent external instantiation. */ private FileLoader() {
}
/** * Reads item information from a file and returns a List of Item objects. * * @param theFile the name of the file to load into a List of Items * @return a List of Item objects created from data in an input file */ public static Map
final Map
final File filePath = Paths.get(theFile).toAbsolutePath().toFile(); try (BufferedReader in = new BufferedReader(new FileReader(filePath))) { // Java 7! String line; while ((line = in.readLine()) != null) { final String[] tokens = line.split(SPLIT_TOKEN); final String uName = tokens[0]; final String uPwd = tokens[1]; final boolean isVIP = Boolean.parseBoolean(tokens[2]); final User u = new User(uName, uPwd, isVIP); userList.put(uName, u); } in.close(); } catch (final IOException e) { e.printStackTrace(); } // no finally block needed to close 'input' with the Java 7 try with resource block
return userList; }
/** * Writes information to the file. * * @param theFile the name of the file to load into a List of Items * @param theUser the user details to write to file */ public static void writeUserToFile(final String theFile, final User theUser) {
try (BufferedWriter out = new BufferedWriter(new FileWriter(theFile, true))) { // Java // 7! final StringBuffer line = new StringBuffer(); line.append(theUser.getMyName() + SPLIT_TOKEN); line.append(theUser.getMyPassword() + SPLIT_TOKEN); line.append(theUser.getMyVIPStatus()); out.write(" "); out.write(line.toString()); } catch (final IOException e) { e.printStackTrace(); } // no finally block needed to close 'input' with the Java 7 try with resource block
} }
1. When you run RentalMain.java you should get the following output Problems Javadoc Declaration Console 3 RentalMain [Java Application] C:Program FilesVava\openjdk-12.0.2_windows-x64_bin jdk Enter 1 or 2 (1. New Registration 2. Login): 2. When 1 is entered the following should be displayed 82 Problems w Javadoc Declaration Console RentalMain [Java Application) C:\Program Files\ava\openjdk-12.0.2_windows-x64_binyjdk- Enter 1 or 2 (1. New Registration 2. Login): 1 You entered option 1 *** Enter Details ****** User Name: 3. After entering the user details for new registration, the following should be displayed If it is successful 3. Problems @ Javadoc Declaration Console x3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
