write account
This commit is contained in:
12
.gitattributes
vendored
Normal file
12
.gitattributes
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# https://help.github.com/articles/dealing-with-line-endings/
|
||||||
|
#
|
||||||
|
# Linux start script should use lf
|
||||||
|
/gradlew text eol=lf
|
||||||
|
|
||||||
|
# These are Windows script files and should use crlf
|
||||||
|
*.bat text eol=crlf
|
||||||
|
|
||||||
|
# Binary files should be left untouched
|
||||||
|
*.jar binary
|
||||||
|
|
||||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Ignore Gradle project-specific cache directory
|
||||||
|
.gradle
|
||||||
|
|
||||||
|
# Ignore Gradle build output directory
|
||||||
|
build
|
||||||
BIN
bin/main/lodge/TestReservations.class
Normal file
BIN
bin/main/lodge/TestReservations.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/AccomodationManager$1.class
Normal file
BIN
bin/main/lodge/reservationsystem/AccomodationManager$1.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/AccomodationManager.class
Normal file
BIN
bin/main/lodge/reservationsystem/AccomodationManager.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/Account.class
Normal file
BIN
bin/main/lodge/reservationsystem/Account.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/AccountException.class
Normal file
BIN
bin/main/lodge/reservationsystem/AccountException.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/AccountList.class
Normal file
BIN
bin/main/lodge/reservationsystem/AccountList.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/AccountReservationList.class
Normal file
BIN
bin/main/lodge/reservationsystem/AccountReservationList.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/Address.class
Normal file
BIN
bin/main/lodge/reservationsystem/Address.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/CabinReservation.class
Normal file
BIN
bin/main/lodge/reservationsystem/CabinReservation.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/DataRepository.class
Normal file
BIN
bin/main/lodge/reservationsystem/DataRepository.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/EmailAddress.class
Normal file
BIN
bin/main/lodge/reservationsystem/EmailAddress.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/HotelReservation.class
Normal file
BIN
bin/main/lodge/reservationsystem/HotelReservation.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/HouseReservation.class
Normal file
BIN
bin/main/lodge/reservationsystem/HouseReservation.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/Reservation.class
Normal file
BIN
bin/main/lodge/reservationsystem/Reservation.class
Normal file
Binary file not shown.
BIN
bin/main/lodge/reservationsystem/ReservationStatus.class
Normal file
BIN
bin/main/lodge/reservationsystem/ReservationStatus.class
Normal file
Binary file not shown.
31
build.gradle
Normal file
31
build.gradle
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by the Gradle 'init' task.
|
||||||
|
*
|
||||||
|
* This is a general purpose Gradle build.
|
||||||
|
* Learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.14.3/samples
|
||||||
|
* This project uses @Incubating APIs which are subject to change.
|
||||||
|
*/
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id 'application'
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClass = 'lodge.reservationsytem.TestReservations'
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
java {
|
||||||
|
srcDirs = ['src/java']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation( files('libs/com.google.code.gson:2.13.1') )
|
||||||
|
}
|
||||||
7
gradle.properties
Normal file
7
gradle.properties
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# This file was generated by the Gradle 'init' task.
|
||||||
|
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
|
||||||
|
|
||||||
|
org.gradle.configuration-cache=true
|
||||||
|
org.gradle.parallel=true
|
||||||
|
org.gradle.caching=true
|
||||||
|
|
||||||
2
gradle/libs.versions.toml
Normal file
2
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# This file was generated by the Gradle 'init' task.
|
||||||
|
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
251
gradlew
vendored
Normal file
251
gradlew
vendored
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
94
gradlew.bat
vendored
Normal file
94
gradlew.bat
vendored
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
BIN
reservationsystem_classdiagram_0828.pdf
Normal file
BIN
reservationsystem_classdiagram_0828.pdf
Normal file
Binary file not shown.
9
settings.gradle
Normal file
9
settings.gradle
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* This file was generated by the Gradle 'init' task.
|
||||||
|
*
|
||||||
|
* The settings file is used to specify which projects to include in your build.
|
||||||
|
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/8.14.3/userguide/multi_project_builds.html in the Gradle documentation.
|
||||||
|
* This project uses @Incubating APIs which are subject to change.
|
||||||
|
*/
|
||||||
|
|
||||||
|
rootProject.name = "reservationsystem"
|
||||||
80
src/java/lodge/TestReservations.java
Normal file
80
src/java/lodge/TestReservations.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package lodge;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import lodge.reservationsystem.AccomodationManager;
|
||||||
|
import lodge.reservationsystem.Account;
|
||||||
|
import lodge.reservationsystem.Address;
|
||||||
|
import lodge.reservationsystem.DataRepository;
|
||||||
|
import lodge.reservationsystem.EmailAddress;
|
||||||
|
|
||||||
|
public final class TestReservations {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
|
AccomodationManager mgr = new AccomodationManager();
|
||||||
|
String home = System.getenv("HOMEDRIVE")+System.getenv("HOMEPATH");
|
||||||
|
home= home.replace("\\", "/") + "/data";
|
||||||
|
DataRepository.setDataStoreRoot(home);
|
||||||
|
|
||||||
|
// 1. Get the list of loaded accounts from Manager
|
||||||
|
|
||||||
|
mgr.loadAll();
|
||||||
|
|
||||||
|
// 2. Retrieve a loaded account object that matches a specific account number
|
||||||
|
|
||||||
|
mgr.retrieveAccount("A######");
|
||||||
|
|
||||||
|
// 3. Add new account object to the list managed by Manager (if account object
|
||||||
|
// already exists on add action with the same account number, it is considered
|
||||||
|
// an error)
|
||||||
|
|
||||||
|
Account acct = mgr.newAccount("767-456-7890",
|
||||||
|
new Address("10 wilco ave", "wilco", "WY", "82801"),
|
||||||
|
new EmailAddress("wilco@wyommin.net"));
|
||||||
|
|
||||||
|
// 4. Request that Manager updates specific account’s files with data stored in
|
||||||
|
// memory
|
||||||
|
mgr.AddAccount(acct);
|
||||||
|
// 5. Add draft lodging reservation to an account (if reservation object already
|
||||||
|
// exists with the same reservation number, it is considered an error)
|
||||||
|
|
||||||
|
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if (acct != null)
|
||||||
|
* acct.addReservation(new HotelReservation());
|
||||||
|
*
|
||||||
|
* // 6. Complete reservation that is associated with an account
|
||||||
|
* Reservation rsrv = null;
|
||||||
|
* acct = null;
|
||||||
|
* acct = mgr.retrieveAccount("A######");
|
||||||
|
* if (acct != null) {
|
||||||
|
* rsrv = acct.retrieve("?######");
|
||||||
|
* rsrv.Complete();
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* // 7. Cancel reservation that is associated with an account
|
||||||
|
* if (acct != null) {
|
||||||
|
* rsrv = acct.retrieve("?######");
|
||||||
|
* if (rsrv != null)
|
||||||
|
* rsrv.Cancel();
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* if (rsrv != null) {
|
||||||
|
* // 8. Change reservation values that can be changed (if reservation is
|
||||||
|
* // cancelled, completed, or for past date, it is considered an error)
|
||||||
|
* rsrv = Reservation.update(rsrv);
|
||||||
|
*
|
||||||
|
* // 9. Request for price per night to be calculated and returned for a
|
||||||
|
* specific
|
||||||
|
* // reservation
|
||||||
|
*
|
||||||
|
* rsrv = Reservation.calculatePricePerNight(rsrv);
|
||||||
|
* // 10. Request for total reservation price to be calculated and returned for
|
||||||
|
* a
|
||||||
|
* // specific reservation
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
System.out.println("Program Completed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
60
src/java/lodge/reservationsystem/AccomodationManager.java
Normal file
60
src/java/lodge/reservationsystem/AccomodationManager.java
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
import java.nio.file.FileVisitResult;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.SimpleFileVisitor;
|
||||||
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
public class AccomodationManager {
|
||||||
|
|
||||||
|
private AccountList account_list = new AccountList();
|
||||||
|
|
||||||
|
public void loadAll() throws Exception {
|
||||||
|
account_list.clear();
|
||||||
|
// walk directories
|
||||||
|
Path rootDir = Paths.get(DataRepository.getPath());
|
||||||
|
Files.walkFileTree(rootDir, new SimpleFileVisitor<Path>() {
|
||||||
|
@Override
|
||||||
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||||
|
System.out.println("File: " + file.toAbsolutePath());
|
||||||
|
// load account number, and content
|
||||||
|
// load reservation files
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
|
||||||
|
System.out.println("Directory: " + dir.toAbsolutePath());
|
||||||
|
// prepare to load account number
|
||||||
|
return FileVisitResult.CONTINUE;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Account retrieveAccount(String acct_id) {
|
||||||
|
return AccountList.retrieveAccount(account_list, acct_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddAccount(Account acct) throws Exception{
|
||||||
|
AccountList.addAccount(account_list, acct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateAccount(Account acct) throws Exception {
|
||||||
|
|
||||||
|
AccountList.save(account_list, acct);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Account newAccount(String phone_number, Address mailing_address, EmailAddress email_address) throws Exception {
|
||||||
|
Account acct = null;
|
||||||
|
try {
|
||||||
|
acct = AccountList.newAccount(phone_number, mailing_address, email_address);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
AccountList.save(account_list, acct);
|
||||||
|
return acct;
|
||||||
|
}
|
||||||
|
}
|
||||||
108
src/java/lodge/reservationsystem/Account.java
Normal file
108
src/java/lodge/reservationsystem/Account.java
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
public class Account {
|
||||||
|
String account_number;
|
||||||
|
String phone_number;
|
||||||
|
Address mailing_address;
|
||||||
|
EmailAddress email_address;
|
||||||
|
|
||||||
|
public Account(
|
||||||
|
String account_number,
|
||||||
|
String phone_number,
|
||||||
|
Address mailing_address,
|
||||||
|
EmailAddress email_address) {
|
||||||
|
this.account_number = account_number;
|
||||||
|
this.phone_number = phone_number;
|
||||||
|
this.mailing_address = mailing_address;
|
||||||
|
this.email_address = email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Account [account_number=" + account_number + ", phone_number=" + phone_number
|
||||||
|
+ ", mailing_address=" + mailing_address + ", email_address=" + email_address
|
||||||
|
+ ", account_number()=" + account_number() + ", phone_number()=" + phone_number()
|
||||||
|
+ ", mailing_address()=" + mailing_address() + ", email_address()=" + email_address()
|
||||||
|
+ "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
//@TODO Write Account out in JSON
|
||||||
|
public static void Write(Account acct) throws IOException {
|
||||||
|
String dataRoot = DataRepository.getPath();
|
||||||
|
dataRoot = dataRoot + "/" + acct.account_number + ".txt";
|
||||||
|
Path path = Paths.get(dataRoot);
|
||||||
|
|
||||||
|
try(BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)){
|
||||||
|
writer.write(acct.toString());
|
||||||
|
writer.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String account_number() {
|
||||||
|
return account_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccount_number(String account_number) {
|
||||||
|
this.account_number = account_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String phone_number() {
|
||||||
|
return phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone_number(String phone_number) {
|
||||||
|
this.phone_number = phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Address mailing_address() {
|
||||||
|
return mailing_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMailing_address(Address mailing_address) {
|
||||||
|
this.mailing_address = mailing_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailAddress email_address() {
|
||||||
|
return email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail_address(EmailAddress email_address) {
|
||||||
|
this.email_address = email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((account_number == null) ? 0 : account_number.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Account other = (Account) obj;
|
||||||
|
if (account_number == null) {
|
||||||
|
if (other.account_number != null)
|
||||||
|
return false;
|
||||||
|
} else if (!account_number.equals(other.account_number))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
57
src/java/lodge/reservationsystem/AccountList.java
Normal file
57
src/java/lodge/reservationsystem/AccountList.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class AccountList extends ArrayList<Account> {
|
||||||
|
|
||||||
|
public static String accountSerial(String phone_number, Address mailing_address, EmailAddress email_address) {
|
||||||
|
return "A" + java.util.Objects.hash(phone_number, mailing_address, email_address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Account newAccount(String phone_number, Address mailing_address, EmailAddress email_address) throws Exception {
|
||||||
|
Account A = new Account(AccountList.accountSerial(phone_number, mailing_address, email_address),
|
||||||
|
phone_number,
|
||||||
|
mailing_address,
|
||||||
|
email_address);
|
||||||
|
|
||||||
|
return A;
|
||||||
|
}
|
||||||
|
// ** Add account throw error if account number is pre-existing. */
|
||||||
|
public static Account addAccount(AccountList account_list, Account account) throws NullPointerException, AccountException {
|
||||||
|
String acctNumber = "";
|
||||||
|
for(Account acct: account_list){
|
||||||
|
if( acct.account_number() == account.account_number() ){
|
||||||
|
acctNumber = acct.account_number();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!acctNumber.isEmpty()) {
|
||||||
|
throw new AccountException("Account exists, duplicates not allowed.");
|
||||||
|
} else {
|
||||||
|
account_list.add(account);
|
||||||
|
}
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
// save account in edit status
|
||||||
|
public void save(Account acct) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// save accounts in edit status
|
||||||
|
public static void save(AccountList account_list, Account acct) throws Exception {
|
||||||
|
for (Account account : account_list) {
|
||||||
|
Account.Write(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ** Find account return null not-existing. */
|
||||||
|
public static Account retrieveAccount(AccountList account_list, String account_number) {
|
||||||
|
for(Account acct: account_list){
|
||||||
|
if( acct.account_number() == account_number ){
|
||||||
|
return acct;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/java/lodge/reservationsystem/AccountReservationList.java
Normal file
12
src/java/lodge/reservationsystem/AccountReservationList.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class AccountReservationList {
|
||||||
|
|
||||||
|
ArrayList<Reservation> reservation_list = new ArrayList<Reservation>();
|
||||||
|
|
||||||
|
public void addReservation(Reservation reservation) {
|
||||||
|
reservation_list.add(reservation);
|
||||||
|
}
|
||||||
|
}
|
||||||
85
src/java/lodge/reservationsystem/Address.java
Normal file
85
src/java/lodge/reservationsystem/Address.java
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
public final class Address {
|
||||||
|
|
||||||
|
String street;
|
||||||
|
String city;
|
||||||
|
String state;
|
||||||
|
String zip;
|
||||||
|
public Address(String street, String city, String state, String zip) {
|
||||||
|
this.street = street;
|
||||||
|
this.city = city;
|
||||||
|
this.state = state;
|
||||||
|
this.zip = zip;
|
||||||
|
}
|
||||||
|
public String getStreet() {
|
||||||
|
return street;
|
||||||
|
}
|
||||||
|
public void setStreet(String street) {
|
||||||
|
this.street = street;
|
||||||
|
}
|
||||||
|
public String getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
public void setCity(String city) {
|
||||||
|
this.city = city;
|
||||||
|
}
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
public void setState(String state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
public String getZip() {
|
||||||
|
return zip;
|
||||||
|
}
|
||||||
|
public void setZip(String zip) {
|
||||||
|
this.zip = zip;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((street == null) ? 0 : street.hashCode());
|
||||||
|
result = prime * result + ((city == null) ? 0 : city.hashCode());
|
||||||
|
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||||
|
result = prime * result + ((zip == null) ? 0 : zip.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Address other = (Address) obj;
|
||||||
|
if (street == null) {
|
||||||
|
if (other.street != null)
|
||||||
|
return false;
|
||||||
|
} else if (!street.equals(other.street))
|
||||||
|
return false;
|
||||||
|
if (city == null) {
|
||||||
|
if (other.city != null)
|
||||||
|
return false;
|
||||||
|
} else if (!city.equals(other.city))
|
||||||
|
return false;
|
||||||
|
if (state == null) {
|
||||||
|
if (other.state != null)
|
||||||
|
return false;
|
||||||
|
} else if (!state.equals(other.state))
|
||||||
|
return false;
|
||||||
|
if (zip == null) {
|
||||||
|
if (other.zip != null)
|
||||||
|
return false;
|
||||||
|
} else if (!zip.equals(other.zip))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Address [street=" + street + ", city=" + city + ", state=" + state + ", zip=" + zip + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
src/java/lodge/reservationsystem/CabinReservation.java
Normal file
10
src/java/lodge/reservationsystem/CabinReservation.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
public final class CabinReservation extends Reservation {
|
||||||
|
|
||||||
|
//calculate and return the reservation's price
|
||||||
|
public float calculatePrice() {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
19
src/java/lodge/reservationsystem/DataRepository.java
Normal file
19
src/java/lodge/reservationsystem/DataRepository.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
public final class DataRepository {
|
||||||
|
// hard code data store location for storage of
|
||||||
|
// account data files on filesystem
|
||||||
|
private String directoryPath;
|
||||||
|
private static final DataRepository instance = new DataRepository();
|
||||||
|
public static DataRepository getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDataStoreRoot(String direcoryPath){
|
||||||
|
getInstance().directoryPath = direcoryPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getPath() {
|
||||||
|
return getInstance().directoryPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/java/lodge/reservationsystem/EmailAddress.java
Normal file
48
src/java/lodge/reservationsystem/EmailAddress.java
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
public class EmailAddress{
|
||||||
|
String email_address;
|
||||||
|
|
||||||
|
public EmailAddress(String email_address) {
|
||||||
|
this.email_address = email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail_address() {
|
||||||
|
return email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail_address(String email_address) {
|
||||||
|
this.email_address = email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((email_address == null) ? 0 : email_address.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
EmailAddress other = (EmailAddress) obj;
|
||||||
|
if (email_address == null) {
|
||||||
|
if (other.email_address != null)
|
||||||
|
return false;
|
||||||
|
} else if (!email_address.equals(other.email_address))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "EmailAddress [email_address=" + email_address + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
9
src/java/lodge/reservationsystem/HotelReservation.java
Normal file
9
src/java/lodge/reservationsystem/HotelReservation.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
public final class HotelReservation extends Reservation {
|
||||||
|
|
||||||
|
//calculate and return the reservation's price
|
||||||
|
public float calculatePrice() {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/java/lodge/reservationsystem/HouseReservation.java
Normal file
9
src/java/lodge/reservationsystem/HouseReservation.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
public final class HouseReservation extends Reservation {
|
||||||
|
//calculate and return the reservation's price
|
||||||
|
public float calculatePrice() {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
179
src/java/lodge/reservationsystem/Reservation.java
Normal file
179
src/java/lodge/reservationsystem/Reservation.java
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
package lodge.reservationsystem;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
|
||||||
|
public abstract class Reservation {
|
||||||
|
String reservation_number;
|
||||||
|
String physical_address;
|
||||||
|
String mailing_address;
|
||||||
|
|
||||||
|
ZonedDateTime reservation_start_date;
|
||||||
|
ZonedDateTime reservation_end_date;
|
||||||
|
ReservationStatus reservation_status;
|
||||||
|
|
||||||
|
Integer numberOfBeds;
|
||||||
|
Integer numberOfBedRooms;
|
||||||
|
Integer numberOfBathRooms;
|
||||||
|
Integer numberOfFloors;
|
||||||
|
Integer squareFeet;
|
||||||
|
|
||||||
|
Float price;
|
||||||
|
|
||||||
|
public String reservation_number() {
|
||||||
|
return reservation_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReservation_number(String reservation_number) {
|
||||||
|
this.reservation_number = reservation_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String physical_address() {
|
||||||
|
return physical_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhysical_address(String physical_address) {
|
||||||
|
this.physical_address = physical_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String mailing_address() {
|
||||||
|
return mailing_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMailing_address(String mailing_address) {
|
||||||
|
this.mailing_address = mailing_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZonedDateTime reservation_start_date() {
|
||||||
|
return reservation_start_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReservation_start_date(ZonedDateTime reservation_start_date) {
|
||||||
|
this.reservation_start_date = reservation_start_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZonedDateTime reservation_end_date() {
|
||||||
|
return reservation_end_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReservation_end_date(ZonedDateTime reservation_end_date) {
|
||||||
|
this.reservation_end_date = reservation_end_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReservationStatus reservation_status() {
|
||||||
|
return reservation_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReservation_status(ReservationStatus reservation_status) {
|
||||||
|
this.reservation_status = reservation_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer numberOfBeds() {
|
||||||
|
return numberOfBeds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumberOfBeds(Integer numberOfBeds) {
|
||||||
|
this.numberOfBeds = numberOfBeds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer numberOfBedRooms() {
|
||||||
|
return numberOfBedRooms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumberOfBedRooms(Integer numberOfBedRooms) {
|
||||||
|
this.numberOfBedRooms = numberOfBedRooms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer numberOfBathRooms() {
|
||||||
|
return numberOfBathRooms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumberOfBathRooms(Integer numberOfBathRooms) {
|
||||||
|
this.numberOfBathRooms = numberOfBathRooms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer numberOfFloors() {
|
||||||
|
return numberOfFloors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumberOfFloors(Integer numberOfFloors) {
|
||||||
|
this.numberOfFloors = numberOfFloors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer squareFeet() {
|
||||||
|
return squareFeet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSquareFeet(Integer squareFeet) {
|
||||||
|
this.squareFeet = squareFeet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float price() {
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrice(Float price) {
|
||||||
|
this.price = price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reservation() {
|
||||||
|
numberOfBeds = 0;
|
||||||
|
numberOfBedRooms = 0;
|
||||||
|
numberOfBathRooms = 0;
|
||||||
|
numberOfFloors = 0;
|
||||||
|
price = 0.0f;
|
||||||
|
reservation_status = ReservationStatus.Draft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Draft(){
|
||||||
|
this.reservation_status=ReservationStatus.Draft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Cancel() {
|
||||||
|
this.reservation_status=ReservationStatus.Canceled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Complete() {
|
||||||
|
this.reservation_status=ReservationStatus.Completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((reservation_number == null) ? 0 : reservation_number.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Reservation other = (Reservation) obj;
|
||||||
|
if (reservation_number == null) {
|
||||||
|
if (other.reservation_number != null)
|
||||||
|
return false;
|
||||||
|
} else if (!reservation_number.equals(other.reservation_number))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Reservation [reservation_number=" + reservation_number + ", physical_address=" + physical_address
|
||||||
|
+ ", mailing_address=" + mailing_address + ", reservation_start_date=" + reservation_start_date
|
||||||
|
+ ", reservation_end_date=" + reservation_end_date + ", reservation_status=" + reservation_status
|
||||||
|
+ ", numberOfBeds=" + numberOfBeds + ", numberOfBedRooms=" + numberOfBedRooms + ", numberOfBathRooms="
|
||||||
|
+ numberOfBathRooms + ", numberOfFloors=" + numberOfFloors + ", squareFeet=" + squareFeet + ", price="
|
||||||
|
+ price + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public float calculatePricePerNight(){
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract float calculatePrice();
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ package lodge.reservationsystem;
|
|||||||
|
|
||||||
public enum ReservationStatus {
|
public enum ReservationStatus {
|
||||||
Draft,
|
Draft,
|
||||||
Completed,
|
Canceled,
|
||||||
Finished
|
Completed
|
||||||
|
|
||||||
}
|
}
|
||||||
BIN
src/lib/gson-2.13.1.jar
Normal file
BIN
src/lib/gson-2.13.1.jar
Normal file
Binary file not shown.
@@ -1,74 +0,0 @@
|
|||||||
package lodge;
|
|
||||||
|
|
||||||
import lodge.reservationsystem.Account;
|
|
||||||
import lodge.reservationsystem.Address;
|
|
||||||
import lodge.reservationsystem.EmailAddress;
|
|
||||||
//import lodge.reservationsystem.Address;
|
|
||||||
//import lodge.reservationsystem.EmailAddress;
|
|
||||||
import lodge.reservationsystem.ReservationSystemManager;
|
|
||||||
|
|
||||||
public final class TestReservations {
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
|
|
||||||
ReservationSystemManager mgr = new ReservationSystemManager();
|
|
||||||
|
|
||||||
mgr.setDataStoreRoot("~/data");
|
|
||||||
|
|
||||||
// 1. Get the list of loaded accounts from Manager
|
|
||||||
|
|
||||||
mgr.loadAll();
|
|
||||||
|
|
||||||
// 2. Retrieve a loaded account object that matches a specific account number
|
|
||||||
|
|
||||||
mgr.retrieveAccount("A######");
|
|
||||||
|
|
||||||
// 3. Add new account object to the list managed by Manager (if account object
|
|
||||||
// already exists on add action with the same account number, it is considered
|
|
||||||
// an error)
|
|
||||||
|
|
||||||
mgr.newAccount( "456-7890", new Address(), new EmailAddress() );
|
|
||||||
|
|
||||||
|
|
||||||
// 4. Request that Manager updates specific account’s files with data stored in
|
|
||||||
// memory
|
|
||||||
|
|
||||||
// 5. Add draft lodging reservation to an account (if reservation object already
|
|
||||||
// exists with the same reservation number, it is considered an error)
|
|
||||||
Account acct = mgr.retrieveAccount("A######");
|
|
||||||
|
|
||||||
mgr.UpdateAccount( mgr.retrieveAccount("A######") );
|
|
||||||
|
|
||||||
/* if (acct != null)
|
|
||||||
acct.addReservation(new HotelReservation());
|
|
||||||
|
|
||||||
// 6. Complete reservation that is associated with an account
|
|
||||||
Reservation rsrv = null;
|
|
||||||
acct = null;
|
|
||||||
acct = mgr.retrieveAccount("A######");
|
|
||||||
if (acct != null) {
|
|
||||||
rsrv = acct.retrieve("?######");
|
|
||||||
rsrv.Complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 7. Cancel reservation that is associated with an account
|
|
||||||
if (acct != null) {
|
|
||||||
rsrv = acct.retrieve("?######");
|
|
||||||
if (rsrv != null)
|
|
||||||
rsrv.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rsrv != null) {
|
|
||||||
// 8. Change reservation values that can be changed (if reservation is
|
|
||||||
// cancelled, completed, or for past date, it is considered an error)
|
|
||||||
rsrv = Reservation.update(rsrv);
|
|
||||||
|
|
||||||
// 9. Request for price per night to be calculated and returned for a specific
|
|
||||||
// reservation
|
|
||||||
|
|
||||||
rsrv = Reservation.calculatePricePerNight(rsrv);
|
|
||||||
// 10. Request for total reservation price to be calculated and returned for a
|
|
||||||
// specific reservation
|
|
||||||
} */
|
|
||||||
System.out.println("Program Completed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package lodge.reservationsystem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public final class Account {
|
|
||||||
|
|
||||||
String anumber;
|
|
||||||
ArrayList<Reservation> reservation_list = new ArrayList<Reservation>();
|
|
||||||
|
|
||||||
String phone_number;
|
|
||||||
Address mailing_address;
|
|
||||||
EmailAddress email_address;
|
|
||||||
|
|
||||||
public String getAnumber() {
|
|
||||||
return anumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAnumber(String account_number) {
|
|
||||||
this.anumber = account_number;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return super.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj.getClass() != this.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Account other = (Account) obj;
|
|
||||||
if ((this.getAnumber() == null) ? (other.getAnumber() != null)
|
|
||||||
: !this.getAnumber().equals(other.getAnumber())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
return java.util.Objects.hash(getAnumber());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addReservation(Reservation reservation) {
|
|
||||||
reservation_list.add(reservation);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Account newAccount(String phone_number, Address mailing_address, EmailAddress email_address)
|
|
||||||
throws Exception {
|
|
||||||
Account A = new Account();
|
|
||||||
A.anumber = "A" + java.util.Objects.hash(phone_number, mailing_address, email_address);
|
|
||||||
A.phone_number = phone_number;
|
|
||||||
A.mailing_address = mailing_address;
|
|
||||||
A.email_address = email_address;
|
|
||||||
return A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package lodge.reservationsystem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class Accounts extends ArrayList<Account> {
|
|
||||||
|
|
||||||
// ** Add account throw error if account number is pre-existing. */
|
|
||||||
public Account addAccount(Accounts account_list, Account account) throws NullPointerException, Exception {
|
|
||||||
|
|
||||||
if (account_list.stream().map(Account::getAnumber).count() > 0) {
|
|
||||||
throw new AccountException("Account exists, duplicates not allowed.");
|
|
||||||
} else {
|
|
||||||
account_list.add(account);
|
|
||||||
}
|
|
||||||
return account;
|
|
||||||
}
|
|
||||||
|
|
||||||
// save account in edit status
|
|
||||||
public void save(Account acct) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// save accounts in edit status
|
|
||||||
public static void save(Accounts account_list, Account acct) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// ** Find account return null not-existing. */
|
|
||||||
public static Account retrieveAccount(Accounts account_list, String account_number) {
|
|
||||||
Optional<Account> account = account_list.stream().filter(e -> e.getAnumber() == account_number).findFirst();
|
|
||||||
return account.isPresent() ? account.get() : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package lodge.reservationsystem;
|
|
||||||
|
|
||||||
public class Address implements Cloneable {
|
|
||||||
|
|
||||||
public String street;
|
|
||||||
|
|
||||||
public String city;
|
|
||||||
|
|
||||||
public String state;
|
|
||||||
|
|
||||||
public String zip;
|
|
||||||
|
|
||||||
// format and return object's data in XML format
|
|
||||||
public String toString() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create and return a copy of the object
|
|
||||||
public Address clone() throws CloneNotSupportedException {
|
|
||||||
Address result = new Address();
|
|
||||||
|
|
||||||
result.street = this.street;
|
|
||||||
result.city = this.city;
|
|
||||||
result.state = this.state;
|
|
||||||
result.zip = this.zip;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj.getClass() != this.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Account other = (Account) obj;
|
|
||||||
return hashCode() == other.hashCode();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
return java.util.Objects.hash(street, city, state, zip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package lodge.reservationsystem;
|
|
||||||
|
|
||||||
public class CabinReservation extends Reservation {
|
|
||||||
|
|
||||||
//format and return object's data in XML format
|
|
||||||
public String toString() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//create and return a copy of the object
|
|
||||||
public CabinReservation clone() throws CloneNotSupportedException {
|
|
||||||
CabinReservation result = new CabinReservation();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//calculate and return the reservation's price
|
|
||||||
public float calculatePrice() {
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package lodge.reservationsystem;
|
|
||||||
|
|
||||||
public class EmailAddress implements Cloneable{
|
|
||||||
String email_address;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package lodge.reservationsystem;
|
|
||||||
|
|
||||||
public class HotelReservation extends Reservation {
|
|
||||||
|
|
||||||
//format and return object's data in XML format
|
|
||||||
public String toString() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//create and return a copy of the object
|
|
||||||
public HotelReservation clone() throws CloneNotSupportedException {
|
|
||||||
HotelReservation result = new HotelReservation();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//calculate and return the reservation's price
|
|
||||||
public float calculatePrice() {
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package lodge.reservationsystem;
|
|
||||||
|
|
||||||
public class HouseReservation extends Reservation {
|
|
||||||
|
|
||||||
//format and return object's data in XML format
|
|
||||||
public String toString() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//create and return a copy of the object
|
|
||||||
public HotelReservation clone() throws CloneNotSupportedException {
|
|
||||||
HotelReservation result = new HotelReservation();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//calculate and return the reservation's price
|
|
||||||
public float calculatePrice() {
|
|
||||||
return 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package lodge.reservationsystem;
|
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
|
|
||||||
public abstract class Reservation implements Cloneable {
|
|
||||||
|
|
||||||
String reservation_number;
|
|
||||||
String physical_address;
|
|
||||||
String mailing_address;
|
|
||||||
|
|
||||||
ZonedDateTime reservation_start_date;
|
|
||||||
ZonedDateTime reservation_end_date;
|
|
||||||
|
|
||||||
ReservationStatus reservation_status = ReservationStatus.Draft;
|
|
||||||
|
|
||||||
Integer numberOfBeds = 0;
|
|
||||||
Integer numberOfBedRooms = 0;
|
|
||||||
Integer numberOfBathRooms = 0;
|
|
||||||
|
|
||||||
Integer squareFeet = 0;
|
|
||||||
|
|
||||||
Float price = 0.0f;
|
|
||||||
|
|
||||||
// format and return object's data in XML format
|
|
||||||
public String toString() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (obj.getClass() != this.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Reservation other = (Reservation) obj;
|
|
||||||
if ((reservation_number == null) ? (other.reservation_number != null)
|
|
||||||
: !reservation_number.equals(other.reservation_number)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
return java.util.Objects.hash(reservation_number);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create and return a copy of the object
|
|
||||||
public abstract Reservation clone() throws CloneNotSupportedException;
|
|
||||||
|
|
||||||
public void Cancel() throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Complete() throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// public Reservation retrieve( ArrayList<Reservation> reservation_list, String reservation_number) {
|
|
||||||
// Optional<Reservation> reservation = reservation_list.stream()
|
|
||||||
// .filter(e -> e.reservation_number == reservation_number).findFirst();
|
|
||||||
// return reservation.isPresent() ? reservation.get() : null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static Reservation update(Reservation rsrv) {
|
|
||||||
return rsrv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Reservation calculatePricePerNight(Reservation rsrv) {
|
|
||||||
return rsrv;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package lodge.reservationsystem;
|
|
||||||
|
|
||||||
public class ReservationSystemManager {
|
|
||||||
|
|
||||||
Accounts account_list = new Accounts();
|
|
||||||
// hard code data store location for storage of
|
|
||||||
// account data files on filesystem
|
|
||||||
String DATASTOREROOT = "";
|
|
||||||
|
|
||||||
public String getDataStoreRoot() {
|
|
||||||
return DATASTOREROOT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDataStoreRoot(String filePath) {
|
|
||||||
DATASTOREROOT = filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadAll(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Account retrieveAccount(String acct_id){
|
|
||||||
return Accounts.retrieveAccount( account_list, acct_id );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateAccount(Account acct) {
|
|
||||||
|
|
||||||
Accounts.save(account_list, acct);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Account newAccount(String phone_number, Address mailing_address, EmailAddress email_address){
|
|
||||||
Account acct = null;
|
|
||||||
try {
|
|
||||||
acct = Account.newAccount(phone_number, mailing_address, email_address);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Accounts.save(account_list, acct);
|
|
||||||
return acct;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module lodge {
|
|
||||||
exports lodge.reservationsystem;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user