/*
* Programmer and Programming Style:
* Jeremiah Burke O'Neal
* Bachelor of Science in Information Technology Management, 2009
*
* Portfolio Program:
* Storage Device Capacity Analyzer
*
* Original Coursework Reference:
* Jeremiah Burke O'Neal previously created a circle-calculation program
* for Professor Burgher, Ph.D., at San Diego Mesa College on
* Sunday, March 19, 2017.
*
* Academic Integrity and Transformation Notice:
*
* The original college assignment is not included in this file. It is not
* being publicly distributed because another student could copy it and
* improperly submit it as coursework.
*
* ChatGPT created this separate portfolio demonstration by changing the
* program's purpose, input values, calculations, class design, methods,
* properties, prompts, terminology, validation, and report output.
*
* The original program accepted a circle radius and calculated geometric
* measurements. This program instead accepts storage-device information
* and calculates used space, free space, percentage utilization, and a
* storage-health classification.
*
* Specific changes made by ChatGPT include:
*
* 1. Replacing the circle and radius data model with a StorageDevice class.
* 2. Replacing area, diameter, and circumference calculations with storage
* capacity and utilization calculations.
* 3. Adding a device-name field and separate total-capacity and used-space
* properties.
* 4. Adding input validation that prevents blank names, nonnumeric values,
* negative values, and used capacity greater than total capacity.
* 5. Adding overloaded constructors and property validation.
* 6. Adding a storage-status method based on percentage utilization.
* 7. Rewriting the program flow, variable names, comments, prompts,
* methods, formatting, and output report.
* 8. Correcting formatting, spelling, line-break, brace, and copy-and-paste
* errors present in the supplied text.
*
* Removing these comments would not convert this program into the original
* assignment. Its executable logic performs a different task and does not
* calculate a circle's area, diameter, circumference, or other geometric
* measurements.
*
* No source code can honestly be guaranteed to be impossible to reverse
* engineer. This program was instead made functionally unrelated to the
* original assignment and unsuitable for submission as that assignment.
*
* This code resembles the detailed comments, console interaction,
* properties, constructors, validation, and readable method structure
* that Jeremiah Burke O'Neal would use. It was substantially rewritten
* and modified by ChatGPT for safe portfolio publication.
*/
using System;
using static System.Console;
namespace Jeremiah_Storage_Portfolio
{
/*
* This class stores information about a storage device and performs
* capacity and utilization calculations.
*/
public class StorageDevice
{
private string deviceName;
private double totalCapacityGB;
private double usedCapacityGB;
/************************************************************
*
* Default constructor.
*
* Creates an unnamed storage device with zero capacity.
*
************************************************************/
public StorageDevice()
{
deviceName = "Unnamed Device";
totalCapacityGB = 0.00;
usedCapacityGB = 0.00;
}
/************************************************************
*
* Overloaded constructor.
*
* Allows the device name, total capacity, and used capacity
* to be supplied when the object is created.
*
************************************************************/
public StorageDevice(
string deviceNameValue,
double totalCapacityValue,
double usedCapacityValue)
{
DeviceName = deviceNameValue;
TotalCapacityGB = totalCapacityValue;
UsedCapacityGB = usedCapacityValue;
}
///
/// Gets or sets the name assigned to the storage device.
/// A blank name is replaced with "Unnamed Device."
///
public string DeviceName
{
get
{
return deviceName;
}
set
{
if (String.IsNullOrWhiteSpace(value))
{
deviceName = "Unnamed Device";
}
else
{
deviceName = value.Trim();
}
}
}
///
/// Gets or sets the storage device's total capacity in gigabytes.
/// Negative values are changed to zero.
///
public double TotalCapacityGB
{
get
{
return totalCapacityGB;
}
set
{
if (value < 0.00)
{
totalCapacityGB = 0.00;
}
else
{
totalCapacityGB = value;
}
}
}
///
/// Gets or sets the amount of storage currently used.
/// The value cannot be negative or greater than total capacity.
///
public double UsedCapacityGB
{
get
{
return usedCapacityGB;
}
set
{
if (value < 0.00)
{
usedCapacityGB = 0.00;
}
else if (value > totalCapacityGB)
{
usedCapacityGB = totalCapacityGB;
}
else
{
usedCapacityGB = value;
}
}
}
/************************************************************
*
* Calculates the amount of remaining free storage.
*
************************************************************/
public double GetFreeCapacityGB()
{
return TotalCapacityGB - UsedCapacityGB;
}
/************************************************************
*
* Calculates the percentage of the device that is used.
*
************************************************************/
public double GetUsedPercentage()
{
if (TotalCapacityGB <= 0.00)
{
return 0.00;
}
return UsedCapacityGB / TotalCapacityGB * 100.00;
}
/************************************************************
*
* Calculates the percentage of the device that remains free.
*
************************************************************/
public double GetFreePercentage()
{
if (TotalCapacityGB <= 0.00)
{
return 0.00;
}
return GetFreeCapacityGB() / TotalCapacityGB * 100.00;
}
/************************************************************
*
* Returns a storage status based on percentage utilization.
*
************************************************************/
public string GetStorageStatus()
{
double usedPercentage = GetUsedPercentage();
if (usedPercentage >= 95.00)
{
return "Critical: Storage is almost completely full.";
}
if (usedPercentage >= 85.00)
{
return "Warning: Storage capacity is running low.";
}
if (usedPercentage >= 70.00)
{
return "Monitor: Storage use is becoming elevated.";
}
return "Normal: The device has sufficient free space.";
}
}
class StorageCapacityProgram
{
static void Main(string[] args)
{
DisplayIntroduction();
string deviceName = GetDeviceName();
double totalCapacity = GetTotalCapacity();
double usedCapacity = GetUsedCapacity(totalCapacity);
StorageDevice storageDevice = new StorageDevice(
deviceName,
totalCapacity,
usedCapacity
);
DisplayStorageReport(storageDevice);
WriteLine();
Write("Press any key to exit...");
ReadKey();
}
/************************************************************
*
* Displays the program title and explains its purpose.
*
************************************************************/
private static void DisplayIntroduction()
{
Clear();
WriteLine("Jeremiah O'Neal Storage Capacity Analyzer");
WriteLine("=========================================");
WriteLine();
WriteLine(
"This program analyzes the capacity of a storage device."
);
WriteLine(
"You will enter the device name, total capacity, and"
);
WriteLine(
"amount of capacity currently being used."
);
WriteLine();
WriteLine("Press any key to begin...");
ReadKey();
Clear();
}
/************************************************************
*
* Requires the user to enter a storage-device name.
*
************************************************************/
private static string GetDeviceName()
{
string deviceName = "";
while (String.IsNullOrWhiteSpace(deviceName))
{
Write("Storage device name: ");
deviceName = ReadLine();
if (String.IsNullOrWhiteSpace(deviceName))
{
WriteLine(
"The storage device name cannot be blank.\n"
);
}
}
return deviceName.Trim();
}
/************************************************************
*
* Requires a total capacity greater than zero.
*
************************************************************/
private static double GetTotalCapacity()
{
double totalCapacity = 0.00;
bool capacityIsValid = false;
while (!capacityIsValid)
{
Write("Total storage capacity in GB: ");
string enteredValue = ReadLine();
if (Double.TryParse(
enteredValue,
out totalCapacity
) && totalCapacity > 0.00)
{
capacityIsValid = true;
}
else
{
WriteLine(
"Enter a numeric capacity greater than zero.\n"
);
}
}
return totalCapacity;
}
/************************************************************
*
* Requires used capacity to be between zero and the device's
* total capacity.
*
************************************************************/
private static double GetUsedCapacity(double totalCapacity)
{
double usedCapacity = 0.00;
bool capacityIsValid = false;
while (!capacityIsValid)
{
Write("Storage currently used in GB: ");
string enteredValue = ReadLine();
if (!Double.TryParse(
enteredValue,
out usedCapacity
))
{
WriteLine(
"The used capacity must be a numeric value.\n"
);
continue;
}
if (usedCapacity < 0.00)
{
WriteLine(
"The used capacity cannot be negative.\n"
);
continue;
}
if (usedCapacity > totalCapacity)
{
WriteLine(
"Used capacity cannot exceed total capacity.\n"
);
continue;
}
capacityIsValid = true;
}
return usedCapacity;
}
/************************************************************
*
* Displays the completed storage-capacity report.
*
************************************************************/
private static void DisplayStorageReport(
StorageDevice storageDevice)
{
Clear();
WriteLine("STORAGE DEVICE CAPACITY REPORT");
WriteLine("==============================");
WriteLine();
WriteLine(
"Device name: {0}",
storageDevice.DeviceName
);
WriteLine(
"Total capacity: {0:F2} GB",
storageDevice.TotalCapacityGB
);
WriteLine(
"Used capacity: {0:F2} GB",
storageDevice.UsedCapacityGB
);
WriteLine(
"Free capacity: {0:F2} GB",
storageDevice.GetFreeCapacityGB()
);
WriteLine(
"Percentage used: {0:F2}%",
storageDevice.GetUsedPercentage()
);
WriteLine(
"Percentage free: {0:F2}%",
storageDevice.GetFreePercentage()
);
WriteLine();
WriteLine(
"Storage status: {0}",
storageDevice.GetStorageStatus()
);
}
}
}