【发布时间】:2014-11-07 11:00:00
【问题描述】:
这是我的任务:
使用 以下指南:
您的乐器的数据字段应包括字符串数、 表示字符串名称的字符串名称数组(例如 E、A、D、G),以及 布尔字段来确定乐器是否已调谐,以及是否 乐器正在播放。欢迎您添加其他 数据字段,如果你喜欢。
设置已调整和当前正在播放的字段的构造方法 为假。其他方法
- 为乐器调音,
- 开始演奏乐器,然后
- 停止演奏乐器。
您认为合适的其他方法(添加至少一种独特的方法)。
使用图表工具(例如 PPT、Visio)创建 UML 类图 你的选择。准备图表并将它们放在 Word 文档中 以及对您的班级的简要说明。
为您的仪器创建一个 C# 类。确保您的代码匹配 包括您的设计规范和一些最小功能。 例如,如果你调用 violin.play() 方法,你应该在 至少打印小提琴正在演奏的字样。类似的功能应该 当您停止播放、调整或调用您的任何方法时提供。
到目前为止我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace StringedMusInsApp
{
public class Guitarra
{
public static void Main (string[] args);
//variable that stores the guitarra's name
private String nameValue;
//variable to store strings
private int numberOfStringsValue;
private char[] stringsValue = { 'E', 'A', 'D', 'G', 'B', 'E' };
//field for tune of the guitar,
private bool tunedValue;
//field for playing of guitar
private bool playingValue;
//method to set tune and playing false.
public Guitarra()
{
this.tunedValue = false;
this.playingValue = false;
}
// gets and sets
public String Name
{
get
{
return nameValue;
}
set
{
nameValue = value;
}
}
public int NumberOfStrings
{
get
{
return numberOfStringsValue;
}
set
{
numberOfStringsValue = value;
}
}
public void DisplayStringValues()
{
Console.WriteLine("String Values: ");
for (int i = 0; i < stringsValue.Length; i++)
{
Console.Write(stringsValue[i] + " ");
}
Console.WriteLine();
}
public bool Tuned
{
get
{
return tunedValue;
}
set
{
tunedValue = value;
}
}
public bool Playing
{
get
{
return playingValue;
}
set
{
playingValue = value;
}
}
//Method to play the violin
public void playGuitar()
{
Console.WriteLine("The guitar is now playing.");
Playing = true;
}
//Method to sto playing the violin
public void stopGuitar()
{
Console.WriteLine("The guitar has stopped playing.");
Playing = false;
}
//Method to tune the Guitar
public void tuneGuitar()
{
Console.WriteLine("The guitar is tuned.");
Tuned = true;
}
//Method to stop tuning the Guitar
public void stopTuneGuitar()
{
Console.WriteLine("The guitar has stopped tuning.");
Tuned = false;
}
}
}
但我收到此错误:
错误 1 'StringedMusInsApp.Guitarra.Main(string[])' 必须声明一个主体,因为它没有标记为抽象、外部或部分。
【问题讨论】:
-
那会是什么错误?
-
错误 1 'StringedMusInsApp.Guitarra.Main(string[])' 必须声明一个主体,因为它没有标记为抽象、外部或部分。
-
这不时间敏感。明天之前我们不需要这样做。你做。你是在交作业的前一天尝试做作业的人。
-
对不起,我确实在底部指定了我需要帮助,并且我需要它。我只在周末访问互联网,因为互联网在阿富汗是一种小商品,这是我一周内唯一一次。
-
伙计们别再唠叨了,帮帮这家伙,我不知道编辑前的问题是什么样的,但这是他的第一个 C# 程序。您应该有主体方法的主体,删除“;”并添加括号。正如 David 所说,这是您的控制台应用程序的入口点。