制作联系人管理系统 [英] Making Contact Management System

查看:79
本文介绍了制作联系人管理系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欢迎使用联络管理系统

输入您的选择

1添加联系方式

1名称

2联系否

2显示已选择的联系人

3显示所有联系人

4删除任何联系人

5退出



我得到了这个项目,但我遇到了很多问题。我必须在Switch关键字(if-else)上做出这些选择。如果我选择1则继续子类别。它会要求输入名称然后输入编号(编号可以是字符串类)。

如果我选择2,我只能看到选择的联系人,它会显示姓名和联系人编号。 />
如果我选择3,它将显示所有联系号码

如果我选择4,它将删除我选择的联系人。

如果我选择5,它存在并终止。



问题是我必须使用数组,不能使用数据库,我不需要永久存储在数据库上。

很多事情让我很困惑。我不知道......

解决这些问题。用Java写这个程序。

谢谢

Fahad Ahmed

Welcome to Contact Management System
Enter Your Choice
1 Add Contact
1 Name
2 Contact No
2 Show selected contact
3 Show all contacts
4 Delete Any Contact
5 Exit

I am given this project , but i am having so many problems . I have to make these choices on Switch keyword (if-else). If i select 1 it goes on to sub categories . it will ask to enter name and then number(number can be in String class).
If i select 2 , i just can see only select contact , it will show me Name and contact no.
If i select 3, it will show all contact numbers
if i select 4 , it will delete my selected contact.
if i select 5 , it exists and terminate.

The problem is that i have to use arrays, can't use database, i do not need to store on data base for permanent basis .
SO much confused what to do.i don't know...
Solve these things . write this program in Java.
Thank You
Fahad Ahmed

推荐答案

你的解决方案:开始处理问题,使用数组并不困难。



我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。
Your solution: Start working on the problem, using arrays is not that difficult.

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.


使用 ArrayList< CustomClass> 而不是简单的数组。管理数据然后阵列应该更强大和灵活。



Use ArrayList<CustomClass> instead of simple array(s). It should be more powerful and flexible to manage data then arrays.

import java.lang.Math; // header stuff MUST go above the first class
import java.util.ArrayList; 

// our main class becomes a file but the main method is still found
public class ManagementSystem
{
  public static void main(String[] args)
  {
    //create ArrayList of Contact
    ArrayList<Contact> contacts = new ArrayList<Contact>();
    //create new contact
    Contact c = new Contact("Maciej");
    c.setContactNumber(contacts.size()+1);
    System.out.print(c + "\n");
    //add contact to the array of contacts
    contacts.add(c);
    
    //create another contact
    c = new Contact("Raja");
    c.setContactNumber(contacts.size()+1);
    System.out.print(c + "\n");
    //add 
    contacts.add(c);
    //remove Raja's contact from list
    contacts.remove(c);
    System.out.print("Contact 'Raja' has been removed \n");
    System.out.print("List of Contacts contains: " + contacts.size() + " element(s)\n");

  }
}
// this will become its own file too (and these can be in any order)
public class Contact
{
  private String sName = "";
  private int iNumber = 0;

  public Contact(String _Name)
  {
    sName = _Name;
  }

  public void setContactNumber(int _Number){
      iNumber = _Number;
  }
  
  public String toString()
  {
    return iNumber + " - " + sName;
  }
}





返回以下输出:



Returns the following output:

1 - Maciej
2 - Raja
Contact 'Raja' has been removed 
List of Contacts contains: 1 element(s)





您可以尝试以上代码: http://www.compilejava.net/ [ ^ ]



欲了解更多信息,请参阅:

ArayList [ ^ ]

[ ^ ]



You can try above code on: http://www.compilejava.net/[^]

For further information, please see:
ArayList[^]
Classes[^]


这篇关于制作联系人管理系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆