• 0

[C#] "class name is not valid at this point" error


Question

Hey guys,

I'm trying to call a method with 1 argument. However, no matter where I call the method, I get an error saying "class name is not valid at this point."(and in certain places, I also get an error saying "redundant empty statement") The argument I'm calling is a class variable.

Here is my code so it makes a bit more sense with what I'm trying to say

PrintReceipt(Pump aPump);	//Method I'm trying to call

		public static void PrintReceipt(Pump aPump)	//The actual method
		{
			const double amountDispensed = 0;
			DateTime currTime = DateTime.Now;

			Console.WriteLine("\nAUTOMATED FUEL DELIVERY SYSTEM");
			Console.WriteLine("\nRECEIPT");
			Console.WriteLine("\nDate : {0:d}", currTime);
			Console.Write("\nPaid for {1:#.##} litres of ", aPump.getPrice(), amountDispensed);
		}

If anyone can help me out, that'd be great.

Thanks in advance,

Britt.

6 answers to this question

Recommended Posts

  • 0
  Pc_Madness said:
I think I see her problem,

PrintReceipt(Pump aPump);

Is that how your calling the function? You don't need to include the data type (aka Pump) when calling functions.

PrintReceipt(aPump);

should do the job. :)

Thanks for the reply guys!

Pc_Madness, I've tried that, and it throws an error saying a ')' is expected.

  ork said:
If you can post your complete usage in the class maybe i can help. You can snip method implementations if they are large to post.

Yep I'll post my code up

  • 0

            // Scenario 1 - Enter cash limit 
            if (aSystem.getCardReader().getCardSatus() == SystemController.CardStatus_Valid)
            {

                Pump aPump = customer1.getPump();
                // Fuel selection
                aPump.setFuelType(FuelPriceType.Unleaded);
                // set cash
                aPump.setPrice(40);       
                // check credit limit
                // check fuel price with customers selection
                if (customer1.getCreditLimit() > aPump.getPrice())
                {
                    double fuelDelivery = aPump.getPrice() / FuelPriceType.UnleadedPrice;

                    aPump.activate();
                    if (aTank.getTotalLevel() > fuelDelivery)
                    {
                        aPump.setFuelDispensed(fuelDelivery);
                    }
                    PrintReceipt(Pump aPump);
                    aPump.deactivate();
                    aTank.removeFuel(fuelDelivery);
                    customer1.setCreditLimit(customer1.getCreditLimit() - aPump.getPrice());
                    DateTime currTime = DateTime.Now;

Correction: it's no longer throwing the original error which I posted about, however, it's still saying that a ')' is expected even when I include the data type (which is Pump in this case)

  • 0

Where abouts is it saying that the ) is expected? I can't see any missing brackets from the code you've posted.

You definitely don't need to include the data type when calling your function. I don't even know how that could compile to be honest since I would think that it would have a bitch about you declaring a variable with the same name in the same scope. (you're basically passing PrintReceipt a blank Pump)

Edit: Go away wrack you crazy fellow. :p

p.s. Hi :p

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Cool! Something no one wants that eats up storage space and battery life for free! /s
    • GT games are boring compared to Forza (Horizon or Motorsport)
    • Dead By Daylight and three more games join Xbox Free Play Days this weekend by Pulasthi Ariyasinghe As the weekend approaches, Microsoft has brought along another Free Play Days promotion for Game Pass subscribers to jump into. This time, Dead by Daylight, Headbangers: Rhythm Royale, Trailmakers, and Synduality Echo of Ada are all available for Xbox Game Pass Ultimate, Standard, and Core members for no extra cost. As always, any progress made during the weekend also carries over automatically if you decide to purchase a game afterward. From the four games available, Dead by Daylight should be the most familiar to most gamers. The multiplayer four-versus-one asymmetric survival horror game has you assuming the roles of survivors or the killer to see who can come out on top. Next, Headbangers: Rhythm Royale lands as a light-hearted, rhythm-based battle royale game. Up to 30 players can be in a single round, all represented as pigeons, before various mini-games involving increasingly difficult rhythm challenges get thrown at the group. The last remaining pigeon becomes the "Master Headbanger." Meanwhile, Trailmakers is a popular sandbox experience where you and your friends construct physics-based vehicles. A wide range of modular parts are offered for making these vehicles, with an exploration element also adding more options to search for. Adventure, sandbox, and racing modes arrive as options for playing either solo or in multiplayer. Lastly, the Synduality Echo of Ada is a sci-fi extraction shooter experience where you control mechs as you search for loot while fighting AI and other players. Here are the store links for the announced titles and their supported platforms: Dead by Daylight - $11.99 (Xbox Series X|S, Xbox One) Headbangers: Rhythm Royale - $3.99 (Xbox Series X|S, Xbox One, PC) Trailmakers - $14.99 (Xbox Series X|S, Xbox One, PC) SYNDUALITY Echo of Ada - $29.99 (Xbox Series X|S) This Free Play Days promotion will end on Sunday, June 22, at 11:59 pm PT. Following this, expect another round of games to enter the program next Thursday, June 26.
    • I'm not simping, I'm telling it how it is. This is the norm and has been forever. Profits need to keep growing, it doesn't matter if you are valued at a trillion or a million. As long as you are part of public trading that's the name of the game. If it's cheaper for the company to outsource, they will, and you'll get laid off. Welcome to capitalism 101. Like I said, the problem is the system itself.
  • Recent Achievements

    • First Post
      MikeK13 earned a badge
      First Post
    • One Month Later
      OHI Accounting earned a badge
      One Month Later
    • Week One Done
      OHI Accounting earned a badge
      Week One Done
    • First Post
      Thornskade earned a badge
      First Post
    • Week One Done
      Higante88 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      704
    2. 2
      ATLien_0
      267
    3. 3
      Michael Scrip
      202
    4. 4
      +FloatingFatMan
      172
    5. 5
      Steven P.
      131
  • Tell a friend

    Love Neowin? Tell a friend!