{"id":372,"date":"2024-10-23T19:25:31","date_gmt":"2024-10-23T19:25:31","guid":{"rendered":"https:\/\/sites.wp.odu.edu\/nicoleselo\/?page_id=372"},"modified":"2024-11-15T09:02:17","modified_gmt":"2024-11-15T09:02:17","slug":"java","status":"publish","type":"page","link":"https:\/\/sites.wp.odu.edu\/nicoleselo\/java\/","title":{"rendered":"Java"},"content":{"rendered":"\n<p>Here\u2019s some Java code I created! What started as school projects quickly turned into something much more, as I had a lot of fun working on them. On this page, I\u2019ll showcase three of my favorite projects:<\/p>\n\n\n\n<ol>\n<li><strong>Shrek-Themed ATM<\/strong>: For my first project, I created an ATM inspired by Shrek!<\/li>\n\n\n\n<li><strong>Wizard Grade Book<\/strong>: My second project is a grade book made specifically for wizards.<\/li>\n\n\n\n<li><strong>Flight Reservation Machine<\/strong>: Finally, I built a flight reservation system as my third project.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\"><strong><mark class=\"has-inline-color has-vivid-green-cyan-color\">Shrek-Themed ATM<\/mark><\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"481\" data-id=\"424\" src=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/Untitled4444-2-1024x481.png\" alt=\"\" class=\"wp-image-424\" srcset=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/Untitled4444-2-1024x481.png 1024w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/Untitled4444-2-300x141.png 300w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/Untitled4444-2-768x360.png 768w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/Untitled4444-2-600x282.png 600w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/Untitled4444-2.png 1240w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"675\" data-id=\"425\" src=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spiter-2-1024x675.png\" alt=\"\" class=\"wp-image-425\" srcset=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spiter-2-1024x675.png 1024w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spiter-2-300x198.png 300w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spiter-2-768x506.png 768w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spiter-2-455x300.png 455w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spiter-2.png 1254w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"675\" data-id=\"426\" src=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/donkey-1-1024x675.png\" alt=\"\" class=\"wp-image-426\" srcset=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/donkey-1-1024x675.png 1024w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/donkey-1-300x198.png 300w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/donkey-1-768x506.png 768w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/donkey-1-455x300.png 455w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/donkey-1.png 1254w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\"><mark style=\"background-color:#000000\" class=\"has-inline-color has-vivid-green-cyan-color\"><strong>Shrek Code<\/strong><\/mark><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>    \/\/ Method for withdrawals and teller phares\npublic void withdraw(double amount) {\n    if (amount &gt; 0 &amp;&amp; amount &lt;= Gold) {\n        Gold -= amount;\n        if (getName().equals(\"Shrek The Ogre\")) {\n            System.out.println(\"\\nHere, take your measly \" + amount + \" Gold.\");\n        } else if (getName().equals(\"Donkey\")) {\n            System.out.println(\"\\nThe teller whispers: I guess they do. \\nHere you go!: \" + amount + \" Gold!\");\n        } else if (getName().equals(\"Fiona The Ogre\")) {\n            System.out.println(\"\\nHere you are your Highness!: \" + amount + \" Gold! Would you like anything else?\");\n        } else if (getName().equals(\"Gingerbread Man\")) {\n            System.out.println(\"\\nHere ya go Gingy!: \" + amount + \" Gold! anything else?\");    \n        } else {\n            System.out.println(\"\\nWithdrawal successful. Your new balance is: \" + Gold + \" Gold!\");\n        }\n    } else {\n        if (getName().equals(\"Shrek The Ogre\") &amp;&amp; Gold - amount &gt;= 0) {\n            System.out.println(\"\\nStop wasting my time, Ogre! You don't have that much Gold.\");\n        } else if (getName().equals(\"Donkey\")) {\n            System.out.println(\"\\nGet outta here! You don't need that much Gold, Donkey!\");\n        } else if (getName().equals(\"Fiona The Ogre\")) {\n            System.out.println(\"\\nI'm sorry princess but we can not provide you with that amount.\");\n        } else if (getName().equals(\"Gingerbread Man\")) {\n            System.out.println(\"\\nHaHa! Nice Try. But let's be serious!\");    \n        } else {\n            System.out.println(\"\\nInvalid withdrawal amount or insufficient coins.\");\n        }\n    }\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\"><strong><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-luminous-vivid-amber-color\">Wizard Grade Book<\/mark><\/strong><\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"748\" height=\"364\" data-id=\"418\" src=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/nnnikki-2.png\" alt=\"\" class=\"wp-image-418\" srcset=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/nnnikki-2.png 748w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/nnnikki-2-300x146.png 300w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/nnnikki-2-600x292.png 600w\" sizes=\"(max-width: 748px) 100vw, 748px\" \/><\/figure><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"623\" data-id=\"419\" src=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spells-2-1024x623.png\" alt=\"\" class=\"wp-image-419\" srcset=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spells-2-1024x623.png 1024w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spells-2-300x182.png 300w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spells-2-768x467.png 768w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spells-2-493x300.png 493w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spells-2.png 1148w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<figcaption class=\"blocks-gallery-caption wp-element-caption\"><strong><mark style=\"background-color:#000000\" class=\"has-inline-color has-luminous-vivid-amber-color\">*~Wizard Code ~*<\/mark><\/strong><\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code> \/\/ Helper method to add up all the scores. Math is fun!\n    public static int calculateTotal(int score1, int score2, int score3) {\n        return score1 + score2 + score3;\n    }\n\n    \/\/ Helper method to find the average. More math magic!\n    public static double calculateAverage(int total) {\n        return (double) total \/ 3;\n    }\n\n    \/\/ Helper method to get the super cool letter grade!\n    public static char determineLetterGrade(double average) {\n        \/\/ Let's play with letters and grades!\n        if (average &gt;= 90) {\n            return 'A';\n        } else if (average &gt;= 80) {\n            return 'B';\n        } else if (average &gt;= 70) {\n            return 'C';\n        } else {\n            \/\/ If it's not an A, B, or C, then it's an F. Oops!\n            return 'F';\n        }\n    }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\"><strong><strong><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color has-white-color\">Flight Reservation Machine<\/mark><\/strong><\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"402\" data-id=\"421\" src=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spirit-1024x402.png\" alt=\"\" class=\"wp-image-421\" srcset=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spirit-1024x402.png 1024w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spirit-300x118.png 300w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spirit-768x302.png 768w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spirit-600x236.png 600w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/spirit.png 1120w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"630\" data-id=\"422\" src=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/seated-1024x630.png\" alt=\"\" class=\"wp-image-422\" srcset=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/seated-1024x630.png 1024w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/seated-300x184.png 300w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/seated-768x472.png 768w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/seated-488x300.png 488w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/seated.png 1132w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"656\" data-id=\"423\" src=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/pass-1024x656.png\" alt=\"\" class=\"wp-image-423\" srcset=\"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/pass-1024x656.png 1024w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/pass-300x192.png 300w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/pass-768x492.png 768w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/pass-468x300.png 468w, https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-content\/uploads\/sites\/30249\/2024\/11\/pass.png 1140w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<figcaption class=\"blocks-gallery-caption wp-element-caption\"><strong><mark style=\"background-color:#000000\" class=\"has-inline-color has-vivid-cyan-blue-color\">Flight Code<\/mark><\/strong><\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Flight class to manage reservations and boarding passes\npublic class Flight {\n    \/\/ Static variables defining the futuristic aircraft\n    private static final int ROWS = 7; \/\/ Number of rows in the aircraft\n    private static final int SEATS_PER_ROW = 3; \/\/ Number of seats per row\n    private static char&#091;]&#091;] seatingChart = new char&#091;ROWS]&#091;SEATS_PER_ROW]; \/\/ Seating arrangement matrix\n    private static int seatsTaken = 0; \/\/ Number of seats already reserved\n    private static ArrayList&lt;Passenger&gt; passengerList = new ArrayList&lt;&gt;(); \/\/ List of passengers\n\n    \/\/ Initializing the seating chart of the aircraft\n    static {\n        \/\/ Creating a state-of-the-art seating arrangement\n        \/\/ In the AirX 3000, passengers are seated in a luxurious 7x3 configuration\n        \/\/ with unparalleled comfort and style.\n        \/\/ The future is here!\n        for (int i = 0; i &lt; ROWS; i++) {\n            for (int j = 0; j &lt; SEATS_PER_ROW; j++) {\n                if (i == 0 &amp;&amp; j == 2) {\n                    seatingChart&#091;i]&#091;j] = 'A'; \/\/ 'A' for available seat\n                } else {\n                    seatingChart&#091;i]&#091;j] = 'X'; \/\/ 'X' for unavailable seat\n                }\n            }\n        }\n    }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here\u2019s some Java code I created! What started as school projects quickly turned into something much more, as I had a lot of fun working on them. On this page, I\u2019ll showcase three of my favorite projects: Shrek-Themed ATM Shrek Code Wizard Grade Book Flight Reservation Machine<\/p>\n","protected":false},"author":20434,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-json\/wp\/v2\/pages\/372"}],"collection":[{"href":"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-json\/wp\/v2\/users\/20434"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-json\/wp\/v2\/comments?post=372"}],"version-history":[{"count":5,"href":"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-json\/wp\/v2\/pages\/372\/revisions"}],"predecessor-version":[{"id":428,"href":"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-json\/wp\/v2\/pages\/372\/revisions\/428"}],"wp:attachment":[{"href":"https:\/\/sites.wp.odu.edu\/nicoleselo\/wp-json\/wp\/v2\/media?parent=372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}