| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 665 人关注过本帖
标题:看不懂这个程序,可否帮忙写一下注释,详细一点呀
只看楼主 加入收藏
bta_zgh
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-12-20
收藏
 问题点数:0 回复次数:3 
看不懂这个程序,可否帮忙写一下注释,详细一点呀

using System;

using System.Collections;

using System.Text ;

public class telephonebox

{

private ArrayList telebook;

public telephonebox()

{

telebook = new ArrayList();

}

public void storeScords(String item)

{

telebook.Add(item);

Console.WriteLine("插入成功!");

}

public void deleteItem(int index)

{

if(index <= 0 || index > telebook.Count )

{

Console.WriteLine("无此记录");

}

else

telebook.RemoveAt(index-1);

}

public void listRecords()

{

int n=0;

Console.WriteLine("********************************************************************");

while(n<telebook.Count)

{

Console.WriteLine("{0}.{1}",n+1,telebook[n]);

n++;

}

Console.WriteLine("********************************************************************");

}

public void displayItem(int index)

{

if(index <= 0 || index > telebook.Count )

{

Console.WriteLine("Sorry,no find such Record!");

}

else

{

Console.WriteLine("*******************************************************************************");

Console.WriteLine ("您要查看的记录如下:");

Console.WriteLine(telebook[index-1]);

Console.WriteLine("*******************************************************************************");

}

}

public void getactulAmount()

{

Console.WriteLine("Now the telebook have {0} records",telebook.Count);

}

public static void Main()

{

telephonebox telebook = new telephonebox();

telebook.storeScords("VX,3333333");

telebook.storeScords("FI ,565645645");

Console.WriteLine("********************************************************************");

Console.WriteLine("Welcome to my TELEPHONE BOOK.\n");

telebook.getactulAmount();

telebook.listRecords();

Console.WriteLine("Please acording to bleows and CHOOSE an DATA to edit this TELEPHONE BOOK you want,enter 0 to exit ");

Console.WriteLine("1.LIST all records.");

Console.WriteLine("2.DISPLAY a specific record.");

Console.WriteLine("3.APPEND a new record.");

Console.WriteLine("4.DELETE a specific record.");

Console.WriteLine("5.Show the total AMOUNT of records.");

Console.WriteLine("0.Exit.");

Console.WriteLine("*******************************************************************************");

String choice,new_record;

int num;

do

{

Console.WriteLine("");

Console.Write("please input an DATA option to edit this TELEPHONE BOOK: ");

choice = Console.ReadLine();

switch (choice)

{

case "1":

telebook.listRecords();

break;

case "2":

Console.Write("Which record do you want to Find:");

num = int.Parse(Console.ReadLine());

telebook.displayItem(num);

break;

case"3":

Console.Write("Please input a record, using 逗号 to separate name and phone code :");

new_record= Console.ReadLine();

telebook.storeScords(new_record);

break;

case"4":

Console.Write("Which record do you want to DELETE ,please input a number:");

num = int.Parse(Console.ReadLine());

telebook.deleteItem(num);

Console.WriteLine ("Deleted successful!");

break;

case"5":

telebook.getactulAmount();

break;

case"0":

Console.WriteLine("telebook has exited");

break;

default:

Console.WriteLine("\nDo you want to find telephone number?\n");

break;

}

}while(choice!="0");

}

}

搜索更多相关主题的帖子: left align 注释 using 
2005-12-25 23:11
marer
Rank: 2
等 级:新手上路
威 望:3
帖 子:928
专家分:0
注 册:2005-7-18
收藏
得分:0 

using System;

using System.Collections;

using System.Text ;

public class telephonebox

{

private ArrayList telebook; //集合,用于存储电话信息

//默认构造

public telephonebox()

{

telebook = new ArrayList(); //初始化集合

}

//插入新电话信息,传入一个字符串信息

public void storeScords(String item)

{

telebook.Add(item); //将传入的参数加入到集合中

Console.WriteLine("插入成功!"); //显示“插入成功”

}

//删除电话记录方法,传入一个整形参数,用于标识要删除哪一条电话记录

public void deleteItem(int index)

{

//假如传入的参数小于零或大于集合的长度,则显示“无此记录”

if(index <= 0 || index > telebook.Count )

{

Console.WriteLine("无此记录");

}

else

telebook.RemoveAt(index-1); //从集合中移除传入的参数所标识的那个对象(由于集合下标是从0开始,所以要减一)

}

//显示集合中所有电话记录的方法

public void listRecords()

{

int n=0; //声明记数变量

Console.WriteLine("********************************************************************");

//只要记数变量小于集合总数,就显示记录

while(n<telebook.Count)

{

Console.WriteLine("{0}.{1}",n+1,telebook[n]); //显示:n.电话

n++; //记数变量增一

}

Console.WriteLine("********************************************************************");

}

//显示单个电话记录的方法,接收一个整型变量,用于标识要显示

public void displayItem(int index)

{ //如果传入参数小于0或大于集合的总数,则显示“Sorry,no find such Record!"

if(index <= 0 || index > telebook.Count )

{

Console.WriteLine("Sorry,no find such Record!");

}

else

{

Console.WriteLine("*******************************************************************************");

Console.WriteLine ("您要查看的记录如下:");

Console.WriteLine(telebook[index-1]); //显示所需电话记录

Console.WriteLine("*******************************************************************************");

}

}

//显示记录总数量的方法

public void getactulAmount()

{

Console.WriteLine("Now the telebook have {0} records",telebook.Count); //显示集合的总数量

}

//Main方法

public static void Main()

{

telephonebox telebook = new telephonebox(); //实例化telephonebox类

telebook.storeScords("VX,3333333"); //插入新记录

telebook.storeScords("FI ,565645645"); //插入新记录

Console.WriteLine("********************************************************************");

Console.WriteLine("Welcome to my TELEPHONE BOOK.\n");

telebook.getactulAmount(); //显示记录总数量

telebook.listRecords(); //显示所有电话记录

//以下为显示菜单项,输入0为退出,输入1为显示全部,2为显示一个,3为添加一个,4为删除一个记录,5为显示总量

Console.WriteLine("Please acording to bleows and CHOOSE an DATA to edit this TELEPHONE BOOK you want,enter 0 to exit ");

Console.WriteLine("1.LIST all records.");

Console.WriteLine("2.DISPLAY a specific record.");

Console.WriteLine("3.APPEND a new record.");

Console.WriteLine("4.DELETE a specific record.");

Console.WriteLine("5.Show the total AMOUNT of records.");

Console.WriteLine("0.Exit.");

Console.WriteLine("*******************************************************************************");

String choice,new_record;

int num;

do

{

Console.WriteLine("");

Console.Write("please input an DATA option to edit this TELEPHONE BOOK: ");

choice = Console.ReadLine();

switch (choice)

{ //如果choice变量为1则显示集合中所有电话记录

case "1":

telebook.listRecords();

break;

//如果为2,则显示按照num来显示记录

case "2":

Console.Write("Which record do you want to Find:");

num = int.Parse(Console.ReadLine());

telebook.displayItem(num);

break;

//如果为3 case"3":

Console.Write("Please input a record, using 逗号 to separate name and phone code :");

new_record= Console.ReadLine();

telebook.storeScords(new_record); //插入新记录

break;

//如果为4,根据num删除记录

case"4":

Console.Write("Which record do you want to DELETE ,please input a number:");

num = int.Parse(Console.ReadLine());

telebook.deleteItem(num);

Console.WriteLine ("Deleted successful!");

break;

//如果为5,则显示记录总数

case"5":

telebook.getactulAmount();

break;

case"0":

Console.WriteLine("telebook has exited");

break;

default:

Console.WriteLine("\nDo you want to find telephone number?\n");

break;

}

}while(choice!="0");

}

}
但是我感觉这个程序可能无法正常运行!!


public class 人生历程 extends Thread{public void run(){while(true){努力,努力,再努力!!;Thread.sleep(0);}}}
2005-12-26 11:52
shadow916
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-12-27
收藏
得分:0 

楼上好强,偶是新手,刚好学习一下!


天下没有不错的程序!
2005-12-27 12:29
LACOLOR
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-12-27
收藏
得分:0 

刚能看懂~


ANTIQUE
2005-12-28 14:21
快速回复:看不懂这个程序,可否帮忙写一下注释,详细一点呀
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029661 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved