cws/main_cw01.tex
changeset 356 d1046d9d3213
parent 345 40657f9a4e4a
child 396 3ffe978a5664
equal deleted inserted replaced
355:bc3980949af2 356:d1046d9d3213
     6 
     6 
     7 
     7 
     8 
     8 
     9 \begin{document}
     9 \begin{document}
    10 
    10 
    11 \section*{Core Part 6 (Scala, 7 Marks)}
    11 \section*{Main Part 1 (Scala, 7 Marks)}
    12 
    12 
    13 \IMPORTANT{This part is about Scala. It is due on \cwSIXa{} at 5pm and worth 7\%.}
    13 \IMPORTANT{This part is about Scala. It is due on \cwSIXa{} at 5pm and worth 7\%.}
    14 
    14 
    15 \noindent
    15 \noindent
    16 Also note that the running time of each part will be restricted to a
    16 Also note that the running time of each part will be restricted to a
    43 \end{lstlisting}%$
    43 \end{lstlisting}%$
    44 
    44 
    45 \subsection*{Hints}
    45 \subsection*{Hints}
    46 
    46 
    47 \noindent
    47 \noindent
    48 \textbf{For the Core Part:} useful string functions:
    48 \textbf{For the Main Part:} useful string functions:
    49 \texttt{.startsWith(...)} for checking whether a string has a given
    49 \texttt{.startsWith(...)} for checking whether a string has a given
    50 prefix, \texttt{\_ ++ \_} for concatenating two strings; useful option
    50 prefix, \texttt{\_ ++ \_} for concatenating two strings; useful option
    51 functions: \texttt{.flatten} flattens a list of options such that it
    51 functions: \texttt{.flatten} flattens a list of options such that it
    52 filters way all \texttt{None}'s, \texttt{Try(...).getOrElse ...} runs
    52 filters way all \texttt{None}'s, \texttt{Try(...).getOrElse ...} runs
    53 some code that might raise an exception---if yes, then a default value
    53 some code that might raise an exception---if yes, then a default value
    62 \textbf{Note!} Fortunately Scala supports operator overloading. But
    62 \textbf{Note!} Fortunately Scala supports operator overloading. But
    63 make sure you understand the difference between \texttt{100 / 3} and
    63 make sure you understand the difference between \texttt{100 / 3} and
    64 \texttt{100.0 / 3}!
    64 \texttt{100.0 / 3}!
    65 
    65 
    66 \newpage
    66 \newpage
    67 \subsection*{Core Part (7 Marks, file drumb.scala)}
    67 \subsection*{Main Part (7 Marks, file drumb.scala)}
    68 
    68 
    69 A purely fictional character named Mr T.~Drumb inherited in 1978
    69 A purely fictional character named Mr T.~Drumb inherited in 1978
    70 approximately 200 Million Dollar from his father. Mr Drumb prides
    70 approximately 200 Million Dollar from his father. Mr Drumb prides
    71 himself to be a brilliant business man because nowadays it is
    71 himself to be a brilliant business man because nowadays it is
    72 estimated he is 3 Billion Dollar worth (one is not sure, of course,
    72 estimated he is 3 Billion Dollar worth (one is not sure, of course,