#Lasagna C#

9 messages · Page 1 of 1 (latest)

cunning knoll
#

So, i got to the second problem of the C# course, i made a program that works perfectly on my PC:

global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

namespace Lasagna1
{
internal class Program
{
static void Main(string[] args)
{
int y = 20;

        // Example usage
        Console.WriteLine("Expected Minutes in Oven: " + Lasagna.ExpectedMinutesInOven());
        Console.WriteLine("Remaining Minutes in Oven: " + Lasagna.RemainingMinutesInOven(y));
        Console.WriteLine("Preparation Time for 3 layers: " + Lasagna.PreparationTimeInMinutes(3));
        Console.WriteLine("Elapsed Time (3 layers, 20 mins in oven): " + Lasagna.ElapsedTimeInMinutes(3, y));
    }
}

class Lasagna
{
    // 1. Expected total oven time in minutes
    public static int ExpectedMinutesInOven()
    {
        
        return 40;
    }

    // 2. Remaining time in oven based on time already in oven
    public static int RemainingMinutesInOven(int x)
    {
        return ExpectedMinutesInOven() - x;
    }

    // 3. Preparation time: 2 minutes per layer
    public static int PreparationTimeInMinutes(int layers)
    {
        return layers * 2;
    }

    // 4. Elapsed time = preparation + time in oven
    public static int ElapsedTimeInMinutes(int layers, int x)
    {
        return PreparationTimeInMinutes(layers) + x;
    }
}

}

It doesnt work on the site's editor and i dont know how to resolve it locally to send it like that. I find it a bit discouraging that the site forces you to resolve a program the way it wants, considering you can resolve something in unlimited ways. And now i cant advance in the course

pseudo escarp
#

I think it'd be useful to make clear your goals and expectations for using Exercism here. The test runner and TDD in general are key components of Exercism, and coding to a specification is pretty commonplace. So in a sense you're going against the grain here which is why you're feeling this friction.

You could always clone locally the C# track repo and work through the exercises without the Exercism site. That gives you flexibility in case you want to extend a particular exercise.

cunning knoll
#

Okay so for anyone that had the same problem as me, dont do anything more than what it wants because thats where the errors appear even if the end product is the same. I tried it like this: class Lasagna
{
public int ExpectedMinutesInOven()
{
return 40;
}

public int RemainingMinutesInOven(int minutesInOven)
{
    return ExpectedMinutesInOven() - minutesInOven;
}

public int PreparationTimeInMinutes(int layers)
{
    return layers * 2;
}

public int ElapsedTimeInMinutes(int layers, int minutesInOven)
{
    return PreparationTimeInMinutes(layers) + minutesInOven;
}

} And it worked

lavish zealot
#
{
    public int ExpectedMinutesInOven()
    {
        return 40;
    }

    public int RemainingMinutesInOven(int minutesInOven)
    {
        return ExpectedMinutesInOven() - minutesInOven;
    }

    public int PreparationTimeInMinutes(int layers)
    {
        return layers * 2;
    }

    public int ElapsedTimeInMinutes(int layers, int minutesInOven)
    {
        return PreparationTimeInMinutes(layers) + minutesInOven;
    }
}
pseudo escarp
pseudo escarp
#

I also should push back on the notion that you can't go beyond what's provided without there being issues. I've done that on other tracks to extend the functionality and try other things as long as you provide the test suite with what it's expecting to find. For example, It's not expecting your Lasagna class to be in a Lasagna1 namespace so it can't find it. In the second code, the test runner can now see your code because you're not in that namespace.

cunning knoll
#

Thank you for everything🙏

lavish zealot