<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Thomas</title>
    <description>The latest articles on DEV Community by Thomas (@phoenix-archer).</description>
    <link>https://dev.to/phoenix-archer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3666789%2F6b834f73-87e0-41fd-a52b-c20515d1a1ea.png</url>
      <title>DEV Community: Thomas</title>
      <link>https://dev.to/phoenix-archer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/phoenix-archer"/>
    <language>en</language>
    <item>
      <title>Building a Console-Based Maintenance Helpdesk System in Java</title>
      <dc:creator>Thomas</dc:creator>
      <pubDate>Thu, 15 Jan 2026 12:44:03 +0000</pubDate>
      <link>https://dev.to/phoenix-archer/building-a-console-based-maintenance-helpdesk-system-in-java-5a8c</link>
      <guid>https://dev.to/phoenix-archer/building-a-console-based-maintenance-helpdesk-system-in-java-5a8c</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;As part of my Digital and Technology Solution Apprenticeship Course module on Introduction to Programming, I have developed a console-based maintenance helpdesk system using Java. The applications aim is to simulate a simple estates maintenance tracker, allowing users to create and view maintenance requests, while administrators can manage technicians, assign technicians to jobs and update the status of the request.&lt;/p&gt;

&lt;p&gt;This blog post will document the development process that I undertook to develop the programme; describing the features of the programme with in-depth description of the code and report on issues i encountered while coding.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Describing the Features&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Below are 3 features from my programme where i will provide an in-depth description of the code that i have written linking the practical implementation to my theoretical understanding of the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  User Input
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Maintenance Request Tracker
===========================
1 - Add a request
2 - View a request
3 - Adminstraitor
4 - Exit
Please choose an option 1-4:
a
Invalid input, please choose a number between 1 and 4
Please choose an option 1-4:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;User input is a core feature of the maintenance helpdesk programme, as all interactions with the application takes place through the console. Java's &lt;code&gt;Scanner&lt;/code&gt; class is used to read inputs from the users, allowing them to navigate menu options, create maintenance requests, and enter reference number when they wish to update or close jobs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int choice = 0; // Stores the menu option chosen by the user.
boolean validChoice = false; // Used to make sure only valid input are accepted.
while (!validChoice) { // Loop keeps asking until user enter a valid number.
    try { // Try/catch is used because nextInt will crash if user enters letter.
        System.out.println("Please choose an option 1-4:");
        choice = input.nextInt(); // Reads user menu choice as a number.
        input.nextLine(); // Clears scanner buffer.
        validChoice = true; // If a valid choice will leave the loop.
    }
    catch (Exception e) { // If incorrect character entered displays error message.
        System.out.println("Invalid input, please choose a number between 1 and 4");
        input.nextLine(); // Clears scanner buffer.
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During development, I learnt that &lt;code&gt;Scanner&lt;/code&gt; handles different types of inputs when reading different data types. Methods such as &lt;code&gt;nextInt()&lt;/code&gt; read only the numerical values entered and leave the newline characters in the input buffer. To make sure this behaviour is handled correctly, I included additional calls to &lt;code&gt;nextLine()&lt;/code&gt; to clear the buffer before accepting more text inputs.&lt;/p&gt;

&lt;p&gt;To improve the reliability of my code further, I introduced input validation with exceptional handling. This made sure that the programme continues to run smoothly even when the user inputs unexpected characters/ or numbers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (!validRef) {
    try {
        System.out.println("Please enter your request reference number:");
        refNumber = input.nextInt();
        input.nextLine();
        validRef = true;
    }
    catch (Exception e) {
        System.out.println("Invalid input, please enter the correct number");
        input.nextLine();
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach reflects the principles of defensive programming, where the programme is designed to handle incorrect user inputs. By validating input and displaying error messages to instruct help users for correct entries therefore the application becomes more robust and user friendly with reduces runtime errors. This links to content which was covered in the bootcamp lecture 3, where we explored handling user input in Java using the &lt;code&gt;Scanner&lt;/code&gt; class.&lt;/p&gt;

&lt;h2&gt;
  
  
  Selection (If, If-Else)
&lt;/h2&gt;

&lt;p&gt;I used selection statements throughout the Maintenance Helpdesk programme to help control how the program responds to user input. In a menu based, console-based application, selection is essential because it determines which part of the program should run next based on which option is chosen by the user.&lt;/p&gt;

&lt;p&gt;In the main menu, user input is determined using a number of &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;else if&lt;/code&gt; statements. Each condition checks the value entered by the user and directs the programme to the associated features such as adding a request, viewing an existing request or accessing the administrator menu.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (choice == 1) {
    addRequest();
}
else if (choice == 2) {
    viewRequest();
}
else if (choice == 3) {
    adminMenu();
}
else if (choice == 4) {
    System.out.println("Exiting Programme");
    running = false;
}
else {
    System.out.println("Invalid Option Choosen");
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From a theoretical perspective, this demonstrates selection and control flow, which is a core concept in structured programming. Condition statements allow the program to follow different path's depending on the logical conditions. I chose &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;else if&lt;/code&gt; statements because each condition shows what will happen when a value is entered, which improves the programmes readability and maintainability while the programme grows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String buildingName = ""; // Will hold the building name once selected.
            boolean validBuilding = false; // Used to keep the looping until user select a valid building.

            while (!validBuilding) { // Loops continues until valid building chosen.

                try { // Try/catch used because it reads a number with nextInt.

                    System.out.println("Building Name (Choose 1-5):");
                    System.out.println("1 - Simon");
                    System.out.println("2 - Beyer");
                    System.out.println("3 - Michael Smith");
                    System.out.println("4 - Stopford");
                    System.out.println("5 - Alan Turing");

                    int buildingChoice = input.nextInt(); // Stores the building option as an integer.
                    input.nextLine(); // Clears scanner buffer.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also used selection elsewhere in the programme to validate choices, such as selecting a building, choosing a priority level or confirming a Y/N action. By continually checking conditions before proceeding, it made sure that only valid options were chosen, again reducing the risk of unexpected behaviours. This links to content which was covered in the bootcamp lecture 4 and Week 1 lecture, where we focused on selection statements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arrays
&lt;/h2&gt;

&lt;p&gt;The maintenance helpdesk system stores and manages data using Java's &lt;code&gt;Arraylist&lt;/code&gt; class. Arraylist are used to hold data on maintenance requests and technicians, allowing the programme to store multiply objects and manage them dynamically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private static ArrayList&amp;lt;Request&amp;gt; request = new ArrayList&amp;lt;&amp;gt;();
private static ArrayList&amp;lt;Technician&amp;gt; technician = new ArrayList&amp;lt;&amp;gt;();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From a theoretical perspective, &lt;code&gt;Arraylist&lt;/code&gt; is part of the Java's framework and represents a dynamic data structure which means the size of the data can grow or shrink. This makes it more suitable than a fixed sized array when it's unsure how much data would be stored in advance. Within the programme the user can continuously enter more requests and even more technicians, so I needed to make sure it has a dynamic structure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request newRequest = new Request(refNumber, requester, telephone, buildingName, description, priority);
request.add(newRequest);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;New Objects are added to these lists as they are created. When a new maintenance request is added, the &lt;code&gt;Request&lt;/code&gt; object is initiated and stored in the request list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private static int findRequest(int refNumber) {

    for (int i = 0; i &amp;lt; request.size(); i++) {
        if (request.get(i).getRefNumber() == refNumber) {
            return i;
        }
    }
    return -1;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To retrieve the data, the programme iterates through the &lt;code&gt;ArrayList&lt;/code&gt; using a loop. When a user enters a reference number to view a request, the system search through the list to find a matching object. If no match is found it returns a -1 which acts as a failure indicator. This links to content which was covered in the week 5 lecture, where we explored Arrays and Arraylists.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Issues Encountered&lt;/strong&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Issue 1: Missing Clearing of the Scanner Buffer
&lt;/h2&gt;

&lt;p&gt;One issued I encountered during development was related to handling user input on Y/N Confirmation menus, as when asking the user whether they wanted to add another request or continue with an action. The programme would repeatedly display the same prompt not allowing the user to progress resulting in an infinity loop. &lt;/p&gt;

&lt;p&gt;This happened because i missed a call to &lt;code&gt;input.nextLine()&lt;/code&gt; after reading the numerical input using &lt;code&gt;nextInt()&lt;/code&gt;. The newline left in the scanner buffer was then picked up by the next &lt;code&gt;nextLine()&lt;/code&gt; call, meaning the programme never waited for the users Y or N entry. To fix this, I made sure the scanner buffer was cleared after every numerical input by adding &lt;code&gt;input.nextLine()&lt;/code&gt; before reading a Y/N response.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;choice = input.nextInt();
input.nextLine();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This resolved the issue and allowed the Y/N Menu to work correct. It helped me understand the importance of handling user input carefully when mixing number and text in a console-based programme.&lt;/p&gt;

&lt;h2&gt;
  
  
  Issue 2: Validating Menu Choices
&lt;/h2&gt;

&lt;p&gt;Another issue I encountered was ensuring that user could only select valid menu options. I quickly learnt in earlier versions that the programme allowed users to enter numbers outside the expected range, which could lead to unexpected behaviours.&lt;/p&gt;

&lt;p&gt;This happened because user input was not always checked to make sure if it matched the available menu options. Entering number outside the menu range would still be accepted by the programme.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (choice &amp;gt;= 1 &amp;amp;&amp;amp; choice &amp;lt;= 4) {
    validChoice = true;
} else {
    System.out.println("Invalid option, please choose between 1 and 4");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To resolve this, I added additional validation checks to ensure that user could only chose valid menu options within the range. If an invalid option was chosen an error message would appear asking the user to re-enter the correct option.&lt;/p&gt;

&lt;p&gt;This improved the overall usability of the programme by preventing invalid selections and directing the user towards to correct path. It was helped me reinforce the importance of validation user input in interactive programmes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Issue 3: Managing reference numbers correctly
&lt;/h2&gt;

&lt;p&gt;Another issue I encountered during the development was managing reference number for maintenance requests and technicians. Each request and technician in the programme needs a unique reference number so that it can be found and retrieved correctly later on in the programme.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// These are used to auto generate reference number for request / technicians
private static int nextRequestRef = 1001;
private static int nextTechNumber = 1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The issue kept occurring because reference numbers were automatically generated using counts such as &lt;code&gt;nextRequestRef&lt;/code&gt; and &lt;code&gt;nextTechNumber&lt;/code&gt;. When I added pre-populated test data at the start of the programme, I forgot to update these counters.  This meant that newly created requests or technicians could be given a reference number that already existed in the programme, which could cause confusion and incorrect behaviour when searching for records.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int refNumber = nextRequestRef;
nextRequestRef++;

Request newRequest = new Request(refNumber, requester, telephone, buildingName, description, priority);
request.add(newRequest);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To resolve this issue, I made sure that the counters were updated after the test data was created, so that any request or technician would continue from the correct reference number. This made sure that the reference number remained unique throughout the programme.&lt;/p&gt;

&lt;p&gt;Ensuring I managed this issue helped me understand the importance of keeping track of the programme's state, especially when the data is generated automatically. It also highlighted to me how such a small issue can lead to larger issues when working with identifiers in the programme that rely on reference numbers for searching and updating the records.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In Conclusion, developing the maintenance helpdesk system helped me improve my understanding of Java programming, particularly around handling user input, using selection statements, and managing data within ArrayLists. As the programme grey in size, I also realised the importance of breaking the code down into separate classes. Doing this helpdesk me partially tidy up my code, making it easier to read, although I would have like to further improve this as I felt I could have made more improvements to the code.&lt;/p&gt;

&lt;p&gt;If I were to develop my code further, I would have like to add the read and write functionality so that the data could be saved and loaded between sessions rather than being reset once the programme closed. Overall though this project helped me understand the importance of good structure, input validation and the need to plan and structure code carefully.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>mmu</category>
    </item>
  </channel>
</rss>
