この課題ではメソッドの使用に問題があります。私の指示は次のとおりですメソッドを使用して変数を渡す際に問題が発生する#
セクションを取得するには、ScheduleStudentPresentationController(コントローラー)のインスタンスを含む変数を使用します。そのメソッドにstudentIdを渡す必要があります。上で定義したstudentId変数をパラメータとして使用します。
最後の行は、studentIdをパラメータとしてメソッドを呼び出し、それをセクションに割り当てる方法だと思いますが、明らかに正しくありません。
これはC#での初めてのプログラミングです。どんな方向性があっても、どのようにシンプルに見えるかは問題ありません。ここで
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace A4_Skeleton
{
public partial class FormStudentSignUpForPresentationSlot : Form
{
private ScheduleStudentPresentationController controller;
private Section selectedSection;
public FormStudentSignUpForPresentationSlot()
{
InitializeComponent();
//***********************************************************************
// 1.
//Instantiate an instance of the ScheduleStudentPresentationController
// and assign it to the class variable named "controller"
//***********************************************************************
controller = new ScheduleStudentPresentationController();
}
private void buttonGetSection_Click(object sender, EventArgs e)
{
// Clear out any residual info
labelSectionInfo.Text = "";
int studentId = 1;
//***********************************************************************
// 2.
// Use the variable that contains an instance of
//ScheduleStudentPresentationController
// to get the section. You will need to pass that method a
//studentId.
// Use the studentId variable defined above as the parameter
//***********************************************************************
Section section = controller(studentId);
がScheduleStudentPresentationController
using System;
using System.Collections.Generic;
namespace A4_Skeleton
{
public class ScheduleStudentPresentationController
{
private PresentationSchedule presentationSchedule;
public ScheduleStudentPresentationController()
{
presentationSchedule = new PresentationSchedule();
}
public Section getSection(int studentId)
{
SectionEnrolledStudent sectionEnrolledStudent = new
SectionEnrolledStudent();
return sectionEnrolledStudent.getSection(studentId);
}
public Dictionary<DateTime, List<Slot>> getAvailableSlots(int
sectionId)
{
return presentationSchedule.getAvailableSlots(sectionId);
}
public bool selectSlot(int sectionId, int studentId, DateTime
slotDate, int slotNum)
{
return presentationSchedule.selectSlot(sectionId, studentId,
slotDate, slotNum);
}
}
}
問題は何ですか? – stybl
学生IDの整数を受け取り、セクションを返すScheduleStudentPresentationControllerで定義されたメソッドを呼び出す必要があります。 – Steve
ScheduleStudentPresentationControllerを表示するように編集しました –