-1

代码应该让用户输入名字和姓氏。

using System;

namespace CSCI_231_Week3_Assn_8
{
    class AccountTest
    {
       static void Main()
       {
          // Create an Account object and assign it to myAccount
          AccountTest myAccount = new AccountTest();

          // Display myAccount's initial name
          Console.WriteLine($"Initial name is: {myAccount.GetName()}");
          // Prompt for and read the name (First & Last) then put the name in the object
          Console.Write("Enter your First & Last name: "); // Propts user to enter their first & last 
          name
          string userName = Console.ReadLine(); // Reads the first & last name entered by user
          myAccount.SetName(userName); // put userName in the myAccount object

          // Display the name stored in the myAccount object
          Console.WriteLine($"myAccount's name is: {myAccount.GetName()}");
       }
    }
 }

所以我错过了一些东西,但我迷失了什么?

4

1 回答 1

0

此代码示例不完整。它没有显示 SetName 和 GetName 方法的实现。

于 2020-02-13T01:02:40.937 回答