\documentclass[noanswers,addpoints,11pt]{exam}
\usepackage{soul}
\usepackage[xetex]{hyperref}
\usepackage[table,usenames]{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{cancel}
\usepackage{datetime}
\usepackage{enumerate}
\usepackage{enumitem}
\usepackage[margin=0.85in]{geometry}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{makecell}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{pstricks}
\usepackage{tabularx}
\usepackage[most]{tcolorbox}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,decorations.pathmorphing,backgrounds,positioning,fit}
\usepackage{xltxtra}

% compact itemized and then enumerated
\setlist{leftmargin=*,
  noitemsep,
  topsep=5pt,
  parsep=0pt,
  partopsep=0pt,
}

\setlist[enumerate]{leftmargin=*,
  itemsep=2pt,
  topsep=0pt,
  parsep=0pt,
  partopsep=0pt,
}

% ----- Fonts -----
\usepackage{fontspec}
\defaultfontfeatures{Scale=MatchLowercase}
% - CONDITIONALLY USE LADDBC FONTS
\IfFontExistsTF{Gentium Book Basic}{
  \setmainfont{Gentium Book Basic}
}{
  \setmainfont{Times New Roman}
}
\IfFontExistsTF{Comic Code}{
  \setmonofont{Comic Code}[
  Scale = 0.85,
  ]
}{
}

\setsansfont{Arial}

% - LISTING FONT = TTFONT
\lstset{
  basicstyle=\ttfamily,
  language={},
}
% ----- Fonts -----
\newcommand{\checkpoint}{{\Large $\checkmark$} }

% classname
\newcommand\assignmentTitle{pPizza - Polymorphic, Decorated Pizza Simulation}
\newcommand\semester{Fall 2023}
\newcommand\className{Computer Science III}
\newcommand\classNumber{CIS~205}
\newcommand\classFullName{\classNumber~\className}
\renewcommand{\dateseparator}{-}
\yyyymmdddate

% /classname

\pagestyle{headandfoot}
\firstpageheader{\classNumber\\\semester}{\assignmentTitle\\~}{\today\\~}
\runningheader{\assignmentTitle}{}{\today}

\newenvironment{showExample}[1]{
  \begingroup
  \renewcommand{\solutiontitle}{\noindent\textbf{Example:}\enspace}
  \printanswers
  \begin{solution}[#1]
  }{
  \end{solution}
  \endgroup
}

\definecolor{outputgray}{gray}{0.95}


\begin{document}
\pointsinrightmargin{}

\section*{Learning Outcomes}
Upon completing this assignment, students should be able to

\begin{itemize}
  \item Use Gradle to initialize a repository.
  \item Add an existing \emph{package} to a new project.
  \item Implement a class \emph{hierarchy} (using
    \lstinline{extends}).
  \item Store objects in a collection that behave \emph{polymorphicly}.
\end{itemize}

\section*{Introduction}

Using your \lstinline{Menu} class from the previous assignment as the
interface, you will implement a pizza ordering simulation. The
simulation will present a main menu where a pizza can be ordered, the
list of ordered pizzas printed, or the program terminated.

When ordering a pizza, the user will select a tomato or pesto base and
then add toppings. The user can end this be either placing the order
for the pizza or canceling it.

\section*{Method}

\subsection*{Class Hierarchy}
The \lstinline{Pizza} class is the base of a hierarchy of classes that
includes two base pizzas, with either tomato or pesto sauce, and two
topped pizzas, one with a single topping and one with two toppings,
one on each half. This relationship is shown in the following class
diagram:

\begin{center}
\includegraphics[width=0.8\textwidth]{pizza}
\end{center}

\begin{description}[font=\ttfamily]
\item[Pizza] The parent of the hierarchy, the \lstinline{Pizza} class
  will be the element type in a
  \lstinline{List}(\lstinline{ArrayList}) so that \emph{any} type of
  pizza can be stored in the collection and the two functions,
  \lstinline{cost} and \lstinline{description} can be called
  \emph{polymorphicly}.
\item[TomatoPie] A crust with tomato sauce on it, this is one of the
  two most basic pizzas available. It costs \$7.00
\item[PestoPie] A crust with basil pesto sauce on it, this is the
  \emph{other} basic pizza available. It costs \$8.50
\item[ToppedPizza] A base \lstinline{Pizza} (must be tracked by the
  objects of this class) \emph{decorated} with a topping. The
  constructor for this class takes a \lstinline{Pizza} to top, a
  \lstinline{String} naming the topping, and a \lstinline{double}
  representing the additional cost of this topping.
\item[HalfToppedPizza] A decorated base \lstinline{Pizza} topped with
  \emph{two} different toppings, each on half of the pie. The
  constructor takes the \lstinline{Pizza} to be topped, \emph{two}
  \lstinline{String}s, one for each topping, and a \lstinline{double}
  for the price of adding both halves.
\end{description}

The \lstinline{cost} is just returned by the \lstinline{TomatoPie} and
\lstinline{PestoPie}. Topped (half or full) pizzas cost whatever the
topped pizza costs plus the cost of this topping.

The \lstinline{description} of the two basic pizza are
\lstinline{"tomato pizza"} and \lstinline{"pesto pizza"}. A topped
pizza with, say, \lstinline{pepperoni}, would return the description
of the pizza it tops, followed by \lstinline{", pepperoni"}. One really
good pizza could then be described as \\
\lstinline{tomato pizza, cheese, onion, pepperoni}

\subsection*{Getting Started}

Start by creating a new directory for your solution to
\lstinline{F23-205-<ccid>-p002} (you \textbf{will} name the repo on
Gitea with that format; call the directory whatever you want).

Initialize the directory with Gradle. Name the project
\lstinline{pizza} and have the source package be \lstinline{shop}.
Modify the created project so that the main class is called
\lstinline{shop.Ordering} and so that \lstinline{gradle run} passes
the keyboard in to the running program.

Compile and run the hello world created by Gradle so you feel like
your code works.

\subsubsection*{\texttt{menu.Menu}}
You will add your \lstinline{Menu} class from the previous assignment
to the project by copying the code into a new \lstinline{menu} package
in the project. For testing the setup, add a menu to
\lstinline{Ordering} with a hard-coded file that it opens. Then call
\lstinline{match}, just to see \lstinline{Ordering} compile with the
\lstinline{Menu}.

Define \lstinline{pizza.Pizza} and \lstinline{pizza.TomatoPie}. Make a
\lstinline{List} of \lstinline{pizza.Pizza} in the main program and
see if you can create and insert a couple of tomato pizza into it and
print their costs and descriptions.

You may want to write a second executable program, down in the
\lstinline{test} folder, that creates each of the different kinds of
pizza with known values and then tests that \lstinline{cost} and
\lstinline{description} work as expected.

\subsection*{Input/Output}
This program will use multiple instances of your \lstinline{Menu}
class, all fields of your \lstinline{Ordering} object (you are
constructing an \lstinline{Ordering} in \lstinline{main} and then
calling \lstinline{run}, right?). The following are examples, not text
you must use.

\subsubsection*{Main Menu}
The main loop in the program is to show this menu and then process the
input the user gives.

\begin{lstlisting}
order - order another pizza
list - show all pizzas already ordered
quit - end the program
\end{lstlisting}

\subsubsection*{Basic Pie Menu}
When the user orders another pizza, start by asking what kind of basic
pie they want to start with

\begin{lstlisting}
tomato - tomato pie
pesto - pesto pie
cancel - cancel this order
\end{lstlisting}

\subsubsection*{Build the Pizza}
This menu will be shown after the user has selected a basic
pizza. Note that the toppings shown are the kind that Oscar the
Grouch, from Sesame Street, might like. You are to pick 4 or 5
toppings that you like for your simulation.

\begin{lstlisting}
glass - add broken glass to pizza
sticks - add twigs and plant debris to pizza
sock - add a dirty gym sock to pizza
lint - add some under-couch lint to pizza
mold - add some moldy, not-supposed-to-be blue cheese
half - add two half toppings
cancel - cancel this order
place - place this order
\end{lstlisting}

\subsubsection*{Half Toppings}
This menu should repeat the toppings in the previous menu. It makes no
sense to order from this menu because user must enter two toppings
before the pizza is ``valid''. I leave it to you to permit
\textbf{cancel} the whole order and/or \textbf{remove} the half and
half topping when the user is using this menu.

Since the same menu will appear twice in a row, even when the user
entered something correctly, use the prompt to let them know what is
going on.


\subsubsection*{Finishing the Order}
When the user cancels an order, go back to main menu loop w/o changing
the list of pizzas.

When the user places an order, put the pizza in the list of pizza and
then go back to the main menu loop.


\subsection*{Design Considerations}


\subsubsection*{Testing}
Use a separate testing program to test whether \lstinline{ToppedPizza}
and \lstinline{HalfToppedPizza} have correctly working
\lstinline{cost} and \lstinline{description} methods.

Remember that you can use commandline input redirection (the
\lstinline{<} character) to feed a file to a running program as the
keyboard. Maybe do this with a final list command to see that the list
has the pizzas that were ordered.

\subsection*{Documentation}

\subsubsection*{\lstinline{README}}
Must document how you tested. How do you know that it is right?

Must include instructions on how to \textbf{compile} and how to
\textbf{run} the program as submitted.

\subsection*{Deliverables}
\textbf{Submission medium}: \lstinline{git} to Gitea at
\lstinline{cs-devel.potsdam.edu}.
\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
