我知道还有其他类似的帖子,但其他帖子并没有帮助我找到问题的解决方案。
我有 1 个表格和 4 个带有方法的类,并且在名为“成本”的类中出现问题,将所有其他 3 个类放入其中。
我将在这里发布四个课程。
头等舱 - Alimentaçao
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Projeto_CustosViagem
{
class Alimentaçao
{
private String descriçao { get; set; }
private double valorTotal { get; set; }
private String nomeRestaurante { get; set; }
public Alimentaçao()
{
valorTotal = 0;
}
public void calcularDespesa(int qtdeRef)
{
valorTotal = qtdeRef * 18;
}
public void listarDespesa()
{
MessageBox.Show("Descrição : " + descriçao + "Valor Total = " + valorTotal + "Nome do Restaurante : " + nomeRestaurante);
}
}
}
二等舱 - 交通
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Projeto_CustosViagem
{
class Transporte
{
private double kmPercorrida { get; set; }
private double valorPedagios { get; set; }
private double valorTotal { get; set; }
public Transporte() {
kmPercorrida = 0;
valorPedagios = 0;
valorTotal = 0;
}
public void calcularDespesa()
{
valorTotal = (kmPercorrida * 8);
}
public void listarDespesa()
{
MessageBox.Show("Km Percorridos : " + kmPercorrida + "Valor dos Pedagios : " + valorPedagios + "Valor Total : " + valorTotal);
}
}
}
三等 - Hospedagem
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Projeto_CustosViagem
{
class Hospedagem
{
private String nomeHotel { get; set; }
private double valorDiaria { get; set; }
private int qtdeDiarias { get; set; }
private double valorTotal { get; set; }
public Hospedagem()
{
valorDiaria = 0;
qtdeDiarias = 0;
valorTotal = 0;
}
public void calcularDespesa()
{
valorTotal = (qtdeDiarias * valorDiaria);
}
public void listarDespesa()
{
MessageBox.Show("Nome do Hotel : " + nomeHotel + "Valor da Diária : " + valorDiaria + "Quantidade de Diárias : " + qtdeDiarias + "Valor total : " + valorTotal);
}
}
}
四级-Custos(问题出在哪里)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Projeto_CustosViagem
{
class Custos
{
public double totalViagem(Alimentaçao A, Transporte T, Hospedagem H)
{
}
}
}
如果你们能帮助我,我会很感激。问题表明并非所有代码路径都会返回值。
您的方法“totalViagem”不返回任何内容,您已将其返回类型设置为 double 但它什么也不返回,这就是您的问题
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)