Skip to content

madiabio/spreadsheet-app

Repository files navigation

Spreadsheet Solution README

Ownership

  • Authors/ Partnership -> Madeline Abio, Sadie Bowen
  • Course -> CS 3500 Software Practice, University of Utah, School of Computing
  • Copyright -> CS 3500 and Madeline Abio and Sadie Bowen This work may not be copied for use in Academic Coursework.

Versioning

Important Dates

  • Solution Start Date -> 01-Sep-2024
  • Partnership Start Date -> 17-Oct-2024
  • Commit Date -> 29-Oct-2024

References:

Our Software Practices

Examples of Good Software Practice (GSP)

1. DRY - Wrote a helper class inside of Spreadsheet.cs titled SpreadsheetUtils which contains a method that returns 
true if a cell name is valid and false otherwise. This avoids repetition as a valid name check is needed
many times in the Spreadsheet and Cell classes.

2. Test methods - Wrote extensive testing for the name syntax test mentioned above in SpreadsheetTests. This ensure that
InvalidNameExceptions are thrown when they should be.

3. Encapsulation - Developers can interface with the software through well documented public methods without needing a 
full understanding of what is occuring 'underneath the hood'.

Resources & Peers

Chat GPT

Query 1:

can you fix this regex pattern for me:
/// <summary>
/// Only alphanumeric characters or (, ), +, -, *, / are valid in a token.
/// </summary>
private const string ValidTokensPattern = @"^[a-zA-Z0-9()+-*/]+$";

Response:

private const string ValidTokensPattern = @"^[a-zA-Z0-9\(\)\+\-\*/]+$";

Query 2.

how do you remove unnecessary .00s etc from a string that represents a number? (ie, "5.000" to "5") with regex

Response:

To remove unnecessary trailing .00 (or other trailing zeros) from a string representing a number, you can use a regular expression to match these patterns and replace them.

Here's a step-by-step approach:

Pattern: The regex pattern should identify:

Trailing zeroes after a decimal point.
Remove the decimal point itself if all digits after the decimal are zeros.
Regex Pattern:

Pattern: @"\.?0+$"
\.: Matches the decimal point (if it exists).
0+: Matches one or more zeros.
?: Makes the decimal point optional (in case there are only trailing zeros).
$: Ensures it matches only at the end of the string.
C# Example:
csharp
Copy code
using System;
using System.Text.RegularExpressions;

public class Program
{
    public static void Main()
    {
        string[] numbers = { "5.000", "123.4500", "10.00", "3.14159", "0.00" };

        foreach (string number in numbers)
        {
            string cleanedNumber = RemoveTrailingZeros(number);
            Console.WriteLine(cleanedNumber);  // Output: 5, 123.45, 10, 3.14159, 0
        }
    }

    public static string RemoveTrailingZeros(string number)
    {
        return Regex.Replace(number, @"\.?0+$", "");
    }
}

Query 3.

how to match if a string is (, +, -, *, /

Response

To match a string that consists of one of the characters (, +, -, *, / in C#, you can use the following regular expression:

Regex Pattern:
^[()+\-*/]$

Consulted Sources

  • Professor de St. Germain's lecture slides were consulted.
  • Consulted Piazza to help learn from other students' questions.
  • ChatGPT

Consulted Peers

  • No peers outside of this partnership were consulted.

About

Spreadsheet application written in C#

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors