the second Objects lab.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <!-- NewPage -->
  3. <html lang="en">
  4. <head>
  5. <!-- Generated by javadoc (1.8.0_144) on Thu May 24 22:37:43 EDT 2018 -->
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>TicketMachine</title>
  8. <meta name="date" content="2018-05-24">
  9. <link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
  10. <script type="text/javascript" src="script.js"></script>
  11. </head>
  12. <body>
  13. <script type="text/javascript"><!--
  14. try {
  15. if (location.href.indexOf('is-external=true') == -1) {
  16. parent.document.title="TicketMachine";
  17. }
  18. }
  19. catch(err) {
  20. }
  21. //-->
  22. var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10};
  23. var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
  24. var altColor = "altColor";
  25. var rowColor = "rowColor";
  26. var tableTab = "tableTab";
  27. var activeTableTab = "activeTableTab";
  28. </script>
  29. <noscript>
  30. <div>JavaScript is disabled on your browser.</div>
  31. </noscript>
  32. <!-- ======== START OF CLASS DATA ======== -->
  33. <div class="header">
  34. <h2 title="Class TicketMachine" class="title">Class TicketMachine</h2>
  35. </div>
  36. <div class="contentContainer">
  37. <ul class="inheritance">
  38. <li>java.lang.Object</li>
  39. <li>
  40. <ul class="inheritance">
  41. <li>TicketMachine</li>
  42. </ul>
  43. </li>
  44. </ul>
  45. <div class="description">
  46. <ul class="blockList">
  47. <li class="blockList">
  48. <hr>
  49. <br>
  50. <pre>public class <span class="typeNameLabel">TicketMachine</span>
  51. extends java.lang.Object</pre>
  52. <div class="block">TicketMachine models a naive ticket machine that issues
  53. flat-fare tickets.
  54. The price of a ticket is specified via the constructor.
  55. It is a naive machine in the sense that it trusts its users
  56. to insert enough money before trying to print a ticket.
  57. It also assumes that users enter sensible amounts.</div>
  58. <dl>
  59. <dt><span class="simpleTagLabel">Version:</span></dt>
  60. <dd>2008.03.30</dd>
  61. <dt><span class="simpleTagLabel">Author:</span></dt>
  62. <dd>David J. Barnes and Michael Kolling</dd>
  63. </dl>
  64. </li>
  65. </ul>
  66. </div>
  67. <div class="summary">
  68. <ul class="blockList">
  69. <li class="blockList">
  70. <!-- ======== CONSTRUCTOR SUMMARY ======== -->
  71. <ul class="blockList">
  72. <li class="blockList"><a name="constructor.summary">
  73. <!-- -->
  74. </a>
  75. <h3>Constructor Summary</h3>
  76. <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
  77. <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
  78. <tr>
  79. <th class="colOne" scope="col">Constructor and Description</th>
  80. </tr>
  81. <tr class="altColor">
  82. <td class="colOne"><code><span class="memberNameLink"><a href="TicketMachine.html#TicketMachine--">TicketMachine</a></span>()</code>&nbsp;</td>
  83. </tr>
  84. </table>
  85. </li>
  86. </ul>
  87. <!-- ========== METHOD SUMMARY =========== -->
  88. <ul class="blockList">
  89. <li class="blockList"><a name="method.summary">
  90. <!-- -->
  91. </a>
  92. <h3>Method Summary</h3>
  93. <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
  94. <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
  95. <tr>
  96. <th class="colFirst" scope="col">Modifier and Type</th>
  97. <th class="colLast" scope="col">Method and Description</th>
  98. </tr>
  99. <tr id="i0" class="altColor">
  100. <td class="colFirst"><code>void</code></td>
  101. <td class="colLast"><code><span class="memberNameLink"><a href="TicketMachine.html#emptry--">emptry</a></span>()</code>
  102. <div class="block">Create a machine that issues tickets of the given price.</div>
  103. </td>
  104. </tr>
  105. <tr id="i1" class="rowColor">
  106. <td class="colFirst"><code>int</code></td>
  107. <td class="colLast"><code><span class="memberNameLink"><a href="TicketMachine.html#getBalance--">getBalance</a></span>()</code>
  108. <div class="block">Return the amount of money already inserted for the
  109. next ticket.</div>
  110. </td>
  111. </tr>
  112. <tr id="i2" class="altColor">
  113. <td class="colFirst"><code>int</code></td>
  114. <td class="colLast"><code><span class="memberNameLink"><a href="TicketMachine.html#getPrice--">getPrice</a></span>()</code>
  115. <div class="block">Return the price of a ticket.</div>
  116. </td>
  117. </tr>
  118. <tr id="i3" class="rowColor">
  119. <td class="colFirst"><code>void</code></td>
  120. <td class="colLast"><code><span class="memberNameLink"><a href="TicketMachine.html#insertMoney-int-">insertMoney</a></span>(int&nbsp;amount)</code>
  121. <div class="block">Receive an amount of money in cents from a customer.</div>
  122. </td>
  123. </tr>
  124. <tr id="i4" class="altColor">
  125. <td class="colFirst"><code>void</code></td>
  126. <td class="colLast"><code><span class="memberNameLink"><a href="TicketMachine.html#printTicket--">printTicket</a></span>()</code>
  127. <div class="block">Print a ticket.</div>
  128. </td>
  129. </tr>
  130. <tr id="i5" class="rowColor">
  131. <td class="colFirst"><code>void</code></td>
  132. <td class="colLast"><code><span class="memberNameLink"><a href="TicketMachine.html#prompt--">prompt</a></span>()</code>&nbsp;</td>
  133. </tr>
  134. <tr id="i6" class="altColor">
  135. <td class="colFirst"><code>void</code></td>
  136. <td class="colLast"><code><span class="memberNameLink"><a href="TicketMachine.html#showPrice--">showPrice</a></span>()</code>&nbsp;</td>
  137. </tr>
  138. <tr id="i7" class="rowColor">
  139. <td class="colFirst"><code>void</code></td>
  140. <td class="colLast"><code><span class="memberNameLink"><a href="TicketMachine.html#TicketMachine2--">TicketMachine2</a></span>()</code>&nbsp;</td>
  141. </tr>
  142. </table>
  143. <ul class="blockList">
  144. <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
  145. <!-- -->
  146. </a>
  147. <h3>Methods inherited from class&nbsp;java.lang.Object</h3>
  148. <code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
  149. </ul>
  150. </li>
  151. </ul>
  152. </li>
  153. </ul>
  154. </div>
  155. <div class="details">
  156. <ul class="blockList">
  157. <li class="blockList">
  158. <!-- ========= CONSTRUCTOR DETAIL ======== -->
  159. <ul class="blockList">
  160. <li class="blockList"><a name="constructor.detail">
  161. <!-- -->
  162. </a>
  163. <h3>Constructor Detail</h3>
  164. <a name="TicketMachine--">
  165. <!-- -->
  166. </a>
  167. <ul class="blockListLast">
  168. <li class="blockList">
  169. <h4>TicketMachine</h4>
  170. <pre>public&nbsp;TicketMachine()</pre>
  171. </li>
  172. </ul>
  173. </li>
  174. </ul>
  175. <!-- ============ METHOD DETAIL ========== -->
  176. <ul class="blockList">
  177. <li class="blockList"><a name="method.detail">
  178. <!-- -->
  179. </a>
  180. <h3>Method Detail</h3>
  181. <a name="emptry--">
  182. <!-- -->
  183. </a>
  184. <ul class="blockList">
  185. <li class="blockList">
  186. <h4>emptry</h4>
  187. <pre>public&nbsp;void&nbsp;emptry()</pre>
  188. <div class="block">Create a machine that issues tickets of the given price.
  189. Note that the price must be greater than zero, and there
  190. are no checks to ensure this.</div>
  191. </li>
  192. </ul>
  193. <a name="getBalance--">
  194. <!-- -->
  195. </a>
  196. <ul class="blockList">
  197. <li class="blockList">
  198. <h4>getBalance</h4>
  199. <pre>public&nbsp;int&nbsp;getBalance()</pre>
  200. <div class="block">Return the amount of money already inserted for the
  201. next ticket.</div>
  202. </li>
  203. </ul>
  204. <a name="getPrice--">
  205. <!-- -->
  206. </a>
  207. <ul class="blockList">
  208. <li class="blockList">
  209. <h4>getPrice</h4>
  210. <pre>public&nbsp;int&nbsp;getPrice()</pre>
  211. <div class="block">Return the price of a ticket.</div>
  212. </li>
  213. </ul>
  214. <a name="insertMoney-int-">
  215. <!-- -->
  216. </a>
  217. <ul class="blockList">
  218. <li class="blockList">
  219. <h4>insertMoney</h4>
  220. <pre>public&nbsp;void&nbsp;insertMoney(int&nbsp;amount)</pre>
  221. <div class="block">Receive an amount of money in cents from a customer.</div>
  222. </li>
  223. </ul>
  224. <a name="printTicket--">
  225. <!-- -->
  226. </a>
  227. <ul class="blockList">
  228. <li class="blockList">
  229. <h4>printTicket</h4>
  230. <pre>public&nbsp;void&nbsp;printTicket()</pre>
  231. <div class="block">Print a ticket.
  232. Update the total collected and
  233. reduce the balance to zero.</div>
  234. </li>
  235. </ul>
  236. <a name="prompt--">
  237. <!-- -->
  238. </a>
  239. <ul class="blockList">
  240. <li class="blockList">
  241. <h4>prompt</h4>
  242. <pre>public&nbsp;void&nbsp;prompt()</pre>
  243. </li>
  244. </ul>
  245. <a name="showPrice--">
  246. <!-- -->
  247. </a>
  248. <ul class="blockList">
  249. <li class="blockList">
  250. <h4>showPrice</h4>
  251. <pre>public&nbsp;void&nbsp;showPrice()</pre>
  252. </li>
  253. </ul>
  254. <a name="TicketMachine2--">
  255. <!-- -->
  256. </a>
  257. <ul class="blockListLast">
  258. <li class="blockList">
  259. <h4>TicketMachine2</h4>
  260. <pre>public&nbsp;void&nbsp;TicketMachine2()</pre>
  261. </li>
  262. </ul>
  263. </li>
  264. </ul>
  265. </li>
  266. </ul>
  267. </div>
  268. </div>
  269. <!-- ========= END OF CLASS DATA ========= -->
  270. </body>
  271. </html>