Advertisement
Guest User

Untitled

a guest
Nov 21st, 2012
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * APPLE PUBLIC SOURCE LICENSE
  3. Version 1.2 - January 4, 2001
  4.  
  5. Please read this License carefully before downloading this software.
  6. By downloading or using this software, you are agreeing to be bound by
  7. the terms of this License. If you do not or cannot agree to the terms
  8. of this License, please do not download or use the software.
  9.  
  10. 1. General; Definitions. This License applies to any program or other
  11. work which Apple Computer, Inc. ("Apple") makes publicly available and
  12. which contains a notice placed by Apple identifying such program or
  13. work as "Original Code" and stating that it is subject to the terms of
  14. this Apple Public Source License version 1.2 (or subsequent version
  15. thereof) ("License"). As used in this License:
  16.  
  17. 1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is
  18. the grantor of rights, (i) claims of patents that are now or hereafter
  19. acquired, owned by or assigned to Apple and (ii) that cover subject
  20. matter contained in the Original Code, but only to the extent
  21. necessary to use, reproduce and/or distribute the Original Code
  22. without infringement; and (b) in the case where You are the grantor of
  23. rights, (i) claims of patents that are now or hereafter acquired,
  24. owned by or assigned to You and (ii) that cover subject matter in Your
  25. Modifications, taken alone or in combination with Original Code.
  26.  
  27. 1.2 "Contributor" means any person or entity that creates or
  28. contributes to the creation of Modifications.
  29.  
  30. 1.3 "Covered Code" means the Original Code, Modifications, the
  31. combination of Original Code and any Modifications, and/or any
  32. respective portions thereof.
  33.  
  34. 1.4 "Deploy" means to use, sublicense or distribute Covered Code other
  35. than for Your internal research and development (R&D) and/or
  36. Personal Use, and includes without limitation, any and all internal
  37. use or distribution of Covered Code within Your business or
  38. organization except for R&D use and/or Personal Use, as well as
  39. direct or indirect sublicensing or distribution of Covered Code by You
  40. to any third party in any form or manner.
  41.  
  42. 1.5 "Larger Work" means a work which combines Covered Code or portions
  43. thereof with code not governed by the terms of this License.
  44.  
  45. 1.6 "Modifications" mean any addition to, deletion from, and/or change
  46. to, the substance and/or structure of the Original Code, any previous
  47. Modifications, the combination of Original Code and any previous
  48. Modifications, and/or any respective portions thereof. When code is
  49. released as a series of files, a Modification is: (a) any addition to
  50. or deletion from the contents of a file containing Covered Code;
  51. and/or (b) any new file or other representation of computer program
  52. statements that contains any part of Covered Code.
  53.  
  54. 1.7 "Original Code" means (a) the Source Code of a program or other
  55. work as originally made available by Apple under this License,
  56. including the Source Code of any updates or upgrades to such programs
  57. or works made available by Apple under this License, and that has been
  58. expressly identified by Apple as such in the header file(s) of such
  59. work; and (b) the object code compiled from such Source Code and
  60. originally made available by Apple under this License.
  61.  
  62. 1.8 "Personal Use" means use of Covered Code by an individual solely
  63. for his or her personal, private and non-commercial purposes. An
  64. individual's use of Covered Code in his or her capacity as an officer,
  65. employee, member, independent contractor or agent of a corporation,
  66. business or organization (commercial or non-commercial) does not
  67. qualify as Personal Use.
  68.  
  69. 1.9 "Source Code" means the human readable form of a program or other
  70. work that is suitable for making modifications to it, including all
  71. modules it contains, plus any associated interface definition files,
  72. scripts used to control compilation and installation of an executable
  73. (object code).
  74.  
  75. 1.10 "You" or "Your" means an individual or a legal entity exercising
  76. rights under this License. For legal entities, "You" or "Your"
  77. includes any entity which controls, is controlled by, or is under
  78. common control with, You, where "control" means (a) the power, direct
  79. or indirect, to cause the direction or management of such entity,
  80. whether by contract or otherwise, or (b) ownership of fifty percent
  81. (50%) or more of the outstanding shares or beneficial ownership of
  82. such entity.
  83.  
  84. 2. Permitted Uses; Conditions & Restrictions. Subject to the terms
  85. and conditions of this License, Apple hereby grants You, effective on
  86. the date You accept this License and download the Original Code, a
  87. world-wide, royalty-free, non-exclusive license, to the extent of
  88. Apple's Applicable Patent Rights and copyrights covering the Original
  89. Code, to do the following:
  90.  
  91. 2.1 You may use, reproduce, display, perform, modify and distribute
  92. Original Code, with or without Modifications, solely for Your internal
  93. research and development and/or Personal Use, provided that in each
  94. instance:
  95.  
  96. (a) You must retain and reproduce in all copies of Original Code the
  97. copyright and other proprietary notices and disclaimers of Apple as
  98. they appear in the Original Code, and keep intact all notices in the
  99. Original Code that refer to this License; and
  100.  
  101. (b) You must include a copy of this License with every copy of Source
  102. Code of Covered Code and documentation You distribute, and You may not
  103. offer or impose any terms on such Source Code that alter or restrict
  104. this License or the recipients' rights hereunder, except as permitted
  105. under Section 6.
  106.  
  107. 2.2 You may use, reproduce, display, perform, modify and Deploy
  108. Covered Code, provided that in each instance:
  109.  
  110. (a) You must satisfy all the conditions of Section 2.1 with respect to
  111. the Source Code of the Covered Code;
  112.  
  113. (b) You must duplicate, to the extent it does not already exist, the
  114. notice in Exhibit A in each file of the Source Code of all Your
  115. Modifications, and cause the modified files to carry prominent notices
  116. stating that You changed the files and the date of any change;
  117.  
  118. (c) You must make Source Code of all Your Deployed Modifications
  119. publicly available under the terms of this License, including the
  120. license grants set forth in Section 3 below, for as long as you Deploy
  121. the Covered Code or twelve (12) months from the date of initial
  122. Deployment, whichever is longer. You should preferably distribute the
  123. Source Code of Your Deployed Modifications electronically (e.g.
  124. download from a web site); and
  125.  
  126. (d) if You Deploy Covered Code in object code, executable form only,
  127. You must include a prominent notice, in the code itself as well as in
  128. related documentation, stating that Source Code of the Covered Code is
  129. available under the terms of this License with information on how and
  130. where to obtain such Source Code.
  131.  
  132. 2.3 You expressly acknowledge and agree that although Apple and each
  133. Contributor grants the licenses to their respective portions of the
  134. Covered Code set forth herein, no assurances are provided by Apple or
  135. any Contributor that the Covered Code does not infringe the patent or
  136. other intellectual property rights of any other entity. Apple and each
  137. Contributor disclaim any liability to You for claims brought by any
  138. other entity based on infringement of intellectual property rights or
  139. otherwise. As a condition to exercising the rights and licenses
  140. granted hereunder, You hereby assume sole responsibility to secure any
  141. other intellectual property rights needed, if any. For example, if a
  142. third party patent license is required to allow You to distribute the
  143. Covered Code, it is Your responsibility to acquire that license before
  144. distributing the Covered Code.
  145.  
  146. 3. Your Grants. In consideration of, and as a condition to, the
  147. licenses granted to You under this License:
  148.  
  149. (a) You hereby grant to Apple and all third parties a non-exclusive,
  150. royalty-free license, under Your Applicable Patent Rights and other
  151. intellectual property rights (other than patent) owned or controlled
  152. by You, to use, reproduce, display, perform, modify, distribute and
  153. Deploy Your Modifications of the same scope and extent as Apple's
  154. licenses under Sections 2.1 and 2.2; and
  155.  
  156. (b) You hereby grant to Apple and its subsidiaries a non-exclusive,
  157. worldwide, royalty-free, perpetual and irrevocable license, under Your
  158. Applicable Patent Rights and other intellectual property rights (other
  159. than patent) owned or controlled by You, to use, reproduce, display,
  160. perform, modify or have modified (for Apple and/or its subsidiaries),
  161. sublicense and distribute Your Modifications, in any form, through
  162. multiple tiers of distribution.
  163.  
  164. 4. Larger Works. You may create a Larger Work by combining Covered
  165. Code with other code not governed by the terms of this License and
  166. distribute the Larger Work as a single product. In each such instance,
  167. You must make sure the requirements of this License are fulfilled for
  168. the Covered Code or any portion thereof.
  169.  
  170. 5. Limitations on Patent License. Except as expressly stated in
  171. Section 2, no other patent rights, express or implied, are granted by
  172. Apple herein. Modifications and/or Larger Works may require additional
  173. patent licenses from Apple which Apple may grant in its sole
  174. discretion.
  175.  
  176. 6. Additional Terms. You may choose to offer, and to charge a fee for,
  177. warranty, support, indemnity or liability obligations and/or other
  178. rights consistent with the scope of the license granted herein
  179. ("Additional Terms") to one or more recipients of Covered Code.
  180. However, You may do so only on Your own behalf and as Your sole
  181. responsibility, and not on behalf of Apple or any Contributor. You
  182. must obtain the recipient's agreement that any such Additional Terms
  183. are offered by You alone, and You hereby agree to indemnify, defend
  184. and hold Apple and every Contributor harmless for any liability
  185. incurred by or claims asserted against Apple or such Contributor by
  186. reason of any such Additional Terms.
  187.  
  188. 7. Versions of the License. Apple may publish revised and/or new
  189. versions of this License from time to time. Each version will be given
  190. a distinguishing version number. Once Original Code has been published
  191. under a particular version of this License, You may continue to use it
  192. under the terms of that version. You may also choose to use such
  193. Original Code under the terms of any subsequent version of this
  194. License published by Apple. No one other than Apple has the right to
  195. modify the terms applicable to Covered Code created under this
  196. License.
  197.  
  198. 8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in
  199. part pre-release, untested, or not fully tested works. The Covered
  200. Code may contain errors that could cause failures or loss of data, and
  201. may be incomplete or contain inaccuracies. You expressly acknowledge
  202. and agree that use of the Covered Code, or any portion thereof, is at
  203. Your sole and entire risk. THE COVERED CODE IS PROVIDED "AS IS" AND
  204. WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND AND APPLE AND
  205. APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" FOR THE
  206. PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM
  207. ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT
  208. NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF
  209. MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR
  210. PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD
  211. PARTY RIGHTS. APPLE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST
  212. INTERFERENCE WITH YOUR ENJOYMENT OF THE COVERED CODE, THAT THE
  213. FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR REQUIREMENTS,
  214. THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR
  215. ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO
  216. ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE
  217. AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY.
  218. You acknowledge that the Covered Code is not intended for use in the
  219. operation of nuclear facilities, aircraft navigation, communication
  220. systems, or air traffic control machines in which case the failure of
  221. the Covered Code could lead to death, personal injury, or severe
  222. physical or environmental damage.
  223.  
  224. 9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO
  225. EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL,
  226. SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING
  227. TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR
  228. ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY,
  229. TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF
  230. APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  231. DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY
  232. REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF
  233. INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY
  234. TO YOU. In no event shall Apple's total liability to You for all
  235. damages (other than as may be required by applicable law) under this
  236. License exceed the amount of fifty dollars ($50.00).
  237.  
  238. 10. Trademarks. This License does not grant any rights to use the
  239. trademarks or trade names "Apple", "Apple Computer", "Mac OS X", "Mac
  240. OS X Server", "QuickTime", "QuickTime Streaming Server" or any other
  241. trademarks or trade names belonging to Apple (collectively "Apple
  242. Marks") or to any trademark or trade name belonging to any
  243. Contributor. No Apple Marks may be used to endorse or promote products
  244. derived from the Original Code other than as permitted by and in
  245. strict compliance at all times with Apple's third party trademark
  246. usage guidelines which are posted at
  247. http://www.apple.com/legal/guidelinesfor3rdparties.html.
  248.  
  249. 11. Ownership. Subject to the licenses granted under this License,
  250. each Contributor retains all rights, title and interest in and to any
  251. Modifications made by such Contributor. Apple retains all rights,
  252. title and interest in and to the Original Code and any Modifications
  253. made by or on behalf of Apple ("Apple Modifications"), and such Apple
  254. Modifications will not be automatically subject to this License. Apple
  255. may, at its sole discretion, choose to license such Apple
  256. Modifications under this License, or on different terms from those
  257. contained in this License or may choose not to license them at all.
  258.  
  259. 12. Termination.
  260.  
  261. 12.1 Termination. This License and the rights granted hereunder will
  262. terminate:
  263.  
  264. (a) automatically without notice from Apple if You fail to comply with
  265. any term(s) of this License and fail to cure such breach within 30
  266. days of becoming aware of such breach;
  267.  
  268. (b) immediately in the event of the circumstances described in Section
  269. 13.5(b); or
  270.  
  271. (c) automatically without notice from Apple if You, at any time during
  272. the term of this License, commence an action for patent infringement
  273. against Apple.
  274.  
  275. 12.2 Effect of Termination. Upon termination, You agree to immediately
  276. stop any further use, reproduction, modification, sublicensing and
  277. distribution of the Covered Code and to destroy all copies of the
  278. Covered Code that are in your possession or control. All sublicenses
  279. to the Covered Code which have been properly granted prior to
  280. termination shall survive any termination of this License. Provisions
  281. which, by their nature, should remain in effect beyond the termination
  282. of this License shall survive, including but not limited to Sections
  283. 3, 5, 8, 9, 10, 11, 12.2 and 13. No party will be liable to any other
  284. for compensation, indemnity or damages of any sort solely as a result
  285. of terminating this License in accordance with its terms, and
  286. termination of this License will be without prejudice to any other
  287. right or remedy of any party.
  288.  
  289. 13. Miscellaneous.
  290.  
  291. 13.1 Government End Users. The Covered Code is a "commercial item" as
  292. defined in FAR 2.101. Government software and technical data rights in
  293. the Covered Code include only those rights customarily provided to the
  294. public as defined in this License. This customary commercial license
  295. in technical data and software is provided in accordance with FAR
  296. 12.211 (Technical Data) and 12.212 (Computer Software) and, for
  297. Department of Defense purchases, DFAR 252.227-7015 (Technical Data --
  298. Commercial Items) and 227.7202-3 (Rights in Commercial Computer
  299. Software or Computer Software Documentation). Accordingly, all U.S.
  300. Government End Users acquire Covered Code with only those rights set
  301. forth herein.
  302.  
  303. 13.2 Relationship of Parties. This License will not be construed as
  304. creating an agency, partnership, joint venture or any other form of
  305. legal association between or among You, Apple or any Contributor, and
  306. You will not represent to the contrary, whether expressly, by
  307. implication, appearance or otherwise.
  308.  
  309. 13.3 Independent Development. Nothing in this License will impair
  310. Apple's right to acquire, license, develop, have others develop for
  311. it, market and/or distribute technology or products that perform the
  312. same or similar functions as, or otherwise compete with,
  313. Modifications, Larger Works, technology or products that You may
  314. develop, produce, market or distribute.
  315.  
  316. 13.4 Waiver; Construction. Failure by Apple or any Contributor to
  317. enforce any provision of this License will not be deemed a waiver of
  318. future enforcement of that or any other provision. Any law or
  319. regulation which provides that the language of a contract shall be
  320. construed against the drafter will not apply to this License.
  321.  
  322. 13.5 Severability. (a) If for any reason a court of competent
  323. jurisdiction finds any provision of this License, or portion thereof,
  324. to be unenforceable, that provision of the License will be enforced to
  325. the maximum extent permissible so as to effect the economic benefits
  326. and intent of the parties, and the remainder of this License will
  327. continue in full force and effect. (b) Notwithstanding the foregoing,
  328. if applicable law prohibits or restricts You from fully and/or
  329. specifically complying with Sections 2 and/or 3 or prevents the
  330. enforceability of either of those Sections, this License will
  331. immediately terminate and You must immediately discontinue any use of
  332. the Covered Code and destroy all copies of it that are in your
  333. possession or control.
  334.  
  335. 13.6 Dispute Resolution. Any litigation or other dispute resolution
  336. between You and Apple relating to this License shall take place in the
  337. Northern District of California, and You and Apple hereby consent to
  338. the personal jurisdiction of, and venue in, the state and federal
  339. courts within that District with respect to this License. The
  340. application of the United Nations Convention on Contracts for the
  341. International Sale of Goods is expressly excluded.
  342.  
  343. 13.7 Entire Agreement; Governing Law. This License constitutes the
  344. entire agreement between the parties with respect to the subject
  345. matter hereof. This License shall be governed by the laws of the
  346. United States and the State of California, except that body of
  347. California law concerning conflicts of law.
  348.  
  349. Where You are located in the province of Quebec, Canada, the following
  350. clause applies: The parties hereby confirm that they have requested
  351. that this License and all related documents be drafted in English. Les
  352. parties ont exige que le present contrat et tous les documents
  353. connexes soient rediges en anglais.
  354.  
  355. EXHIBIT A.
  356.  
  357. "Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
  358. Reserved.
  359.  
  360. This file contains Original Code and/or Modifications of Original Code
  361. as defined in and that are subject to the Apple Public Source License
  362. Version 1.2 (the 'License'). You may not use this file except in
  363. compliance with the License. Please obtain a copy of the License at
  364. http://www.apple.com/publicsource and read it before using this file.
  365.  
  366. The Original Code and all software distributed under the License are
  367. distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  368. EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  369. INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  370. FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  371. Please see the License for the specific language governing rights and
  372. limitations under the License."
  373.  
  374.  */
  375. package com.myimportantcompany.fizzbuzz;
  376.  
  377. /**
  378.  * This is the main class for executing the FizzBuzz Program
  379.  * @author Simon
  380.  *
  381.  */
  382. public class Main {
  383.    
  384.     /**
  385.      * This is the main function for the Program, also called the entry point.
  386.      * @param args These are ignored in this program
  387.      */
  388.     public static void main(String[] args) {
  389.         int limitForFizzBuzzProgram = 100;
  390.         for (int forLoopCounter = 0; forLoopCounter <= limitForFizzBuzzProgram; forLoopCounter = forLoopCounter + 1) {
  391.            
  392.             if(isNumberDivisibleByFiveAndThreeWithoutRemainder(forLoopCounter)) {
  393.                 System.out.println(FizzBuzz.FIZZBUZZ);
  394.             } else if(isNumberDivisibleByFiveWithoutRemainder(forLoopCounter)) {
  395.                 System.out.println(Buzz.BUZZ);
  396.             } else if(isNumberDivisibleByThreeWithoutRemainder(forLoopCounter)) {
  397.                 System.out.println(Fizz.FIZZ);
  398.             } else {
  399.                 System.out.println(forLoopCounter);
  400.             }
  401.         }
  402.     }
  403.    
  404.     /**
  405.      * This function checks whether a given number is divisible by 3 without a remainder
  406.      * @param number the number to be checked
  407.      * @return True if the number is divisible by 3 without a remainder, false otherwise
  408.      */
  409.     public static boolean isNumberDivisibleByThreeWithoutRemainder(int number) {
  410.         if (((number / 3) * 3) == number) {
  411.             return true;
  412.         } else {
  413.             return false;
  414.         }
  415.     }
  416.    
  417.     /**
  418.      * This function checks whether a given number is divisible by 5 without a remainder
  419.      * @param number the number to be checked
  420.      * @return True if the number is divisible by 5 without a remainder, false otherwise
  421.      */
  422.     public static boolean isNumberDivisibleByFiveWithoutRemainder(int number) {
  423.         if (((number / 5) * 5) == number) {
  424.             return true;
  425.         } else {
  426.             return false;
  427.         }
  428.     }
  429.  
  430.     /**
  431.      * This function checks whether a given number is divisible by 5 and 3without a remainder
  432.      * @param number the number to be checked
  433.      * @return True if the number is divisible by 5 and 3 without a remainder, false otherwise
  434.      */
  435.     public static boolean isNumberDivisibleByFiveAndThreeWithoutRemainder(
  436.             int number) {
  437.         boolean checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
  438.         if (((number / 3) * 3) == number) {
  439.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
  440.         } else {
  441.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
  442.         }
  443.  
  444.         if (((number / 5) * 5) == number) {
  445.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
  446.         } else {
  447.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
  448.         }
  449.         return checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder;
  450.     }
  451. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement