Fejl i compile
Hvad er det lige den prøver at fortælle mig der er galt.. ? Vs hvad skal jeg ændre :) ? thxError 1 The best overloaded method match for 'System.Console.WriteLine(bool)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'method group' to 'bool'
Error 3 The best overloaded method match for 'System.Console.WriteLine(bool)' has some invalid arguments
Error 4 Argument '1': cannot convert from 'method group' to 'bool'
-------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace CashRegister
{
class CashRegister
{
public CashRegister()
{
purchase = 0;
payment = 0;
}
public void recordPurchase(double amount)
{
purchase = purchase + amount;
}
public void enterPayment(int dollars, int quarters, int dimes, int nickels, int pennies)
{
payment = dollars + quarters + QUARTER_VALUE + dimes * DIME_VALUE + nickels * NICKEL_VALUE + pennies * PENNY_VALUE;
}
public double giveChange()
{
double change = payment - purchase;
purchase = 0;
payment = 0;
return change;
}
public static readonly double QUARTER_VALUE = 0.25;
public static readonly double DIME_VALUE = 0.1;
private static readonly double NICKEL_VALUE = 0.05;
private static readonly double PENNY_VALUE = 0.01;
private double purchase;
private double payment;
}
}
---------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace CashRegister
{
public class Program
{
public static void Main(string[] args)
{
CashRegister register = new CashRegister();
register.recordPurchase(0.75);
register.recordPurchase(1.5);
register.enterPayment(2, 0, 5, 0, 0);
Console.WriteLine("Change = ");
Console.WriteLine(register.giveChange);
register.recordPurchase(2.25);
register.recordPurchase(19.25);
register.enterPayment(23, 2, 0, 0 , 0);
Console.WriteLine("Change =");
Console.WriteLine(register.giveChange);
}
}
}
