首页 > 编程知识 正文

company实体java(company百度百科)

时间:2023-12-10 13:48:24 阅读:314079 作者:TXVO

本文目录一览:

java作业:创建类Company,属性有:注册编号cno,公司名称cname,所在地区addre

import java.util.HashMap;

import java.util.Map;

import java.util.Scanner;

public class Demo02 {

public static void main(String[] args) throws Exception {

MapInteger, Company map = new HashMapInteger, Company();

Scanner sc = new Scanner(System.in);

for (int i = 0; i  3; i++) {

System.out.println("请输入公司编号:");

int cno = sc.nextInt();

System.out.println("请输入公司名字:");

String cname = sc.next();

System.out.println("请输入公司地址:");

String address = sc.next();

System.out.println("请输入公司员工数:");

int count = sc.nextInt();

System.out.println("请输入公司业务类型:");

String serviceType = sc.next();

map.put(i, new Company(cno, cname, count, address, serviceType));

}

for (int i = 0; i  3; i++) {

System.out.println(map.get(i).display());

}

}

}

class Company{

private int cno;

private String cname;

private int count;

private String address;

private String serviceType;

public Company(int cno, String cname, int count, String address,

String serviceType) {

super();

this.cno = cno;

this.cname = cname;

this.count = count;

this.address = address;

this.serviceType = serviceType;

}

public int getCno() {

return cno;

}

public void setCno(int cno) {

this.cno = cno;

}

public String getCname() {

return cname;

}

public void setCname(String cname) {

this.cname = cname;

}

public int getCount() {

return count;

}

public void setCount(int count) {

this.count = count;

}

public String getAddress() {

return address;

}

public void setAddress(String address) {

this.address = address;

}

public String getServiceType() {

return serviceType;

}

public void setServiceType(String serviceType) {

this.serviceType = serviceType;

}

public String display() {

return "Company [cno=" + cno + ", cname=" + cname + ", count=" + count

+ ", address=" + address + ", serviceType=" + serviceType + "]";

}

}

在java中,customer,company和creditcard类是什么关系?如何编写代码

你这问题问的,好歹有个背景啊。。。

靠猜测的分析如下,客户(customer),公司(company),信用卡(creditcard)

公司和客户是一对多的关系,客户和信用卡是一对多的关系;

具体代码就是公司类中有客户的一个集合,客户类中有信用卡的集合;

信用卡类中有客户的对象引用,客户类中有公司的对象应用;

以及各自类中的属性以及对应的get、set方法;

每个类的行为方法。

用JAVA语言创建一个名为Company的包的语句是【 】

java中包相当于window中的目录,在类中使用package指定类所在包相当于所在的目录层次,java中没有创建包的语句。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。