java设备管理系统免费源码
以下是一个Java设备管理系统的免费源码示例,超过500字:
```java
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Device
private String deviceName;
private String deviceType;
public Device(String deviceName, String deviceType)
this.deviceName = deviceName;
this.deviceType = deviceType;
}
public String getDeviceName。
return deviceName;
}
public void setDeviceName(String deviceName)
this.deviceName = deviceName;
}
public String getDeviceType。
return deviceType;
}
public void setDeviceType(String deviceType)
this.deviceType = deviceType;
}
class DeviceManagementSystem
private List<Device> devices;
public DeviceManagementSystem。
devices = new ArrayList<>(;
}
public void addDevice(Device device)
devices.add(device);
System.out.println("Device added successfully!");
}
public void removeDevice(String deviceName)
boolean removed = false;
for (Device device : devices)
if (DeviceName(.equals(deviceName))
ve(device);
removed = true;
break;
}
}
if (removed)
System.out.println("Device removed successfully!");
} else
System.out.println("Device not found!");
}
}
public void displayDevices。
if (devices.isEmpty。
System.out.println("No devices found!");
} else
for (Device device : devices)
System.out.println("Device Name: " + DeviceName(;
System.out.println("Device Type: " + DeviceType(;
System.out.println("-------------------------");
}
}
}
public class Main
public static void main(String[] args)
DeviceManagementSystem system = new DeviceManagementSystem(;
Scanner scanner = new Scanner(System.in);
while (true)
System.out.println("1. Add device");
System.out.println("2. Remove device");
System.out.println("3. Display devices");
System.out.println("4. Quit");
System.out.print("Enter your choice: ");
int choice = 某tInt(;
某tLine(;
switch (choice)
case 1:
System.out.print("Enter device name: ");
String deviceName = 某tLine(;
System.out.print("Enter device type: ");
String deviceType = 某tLine(;
java在哪里可以免费自学Device device = new Device(deviceName, deviceType);
system.addDevice(device);
break;
case 2:
System.out.print("Enter device name: ");
String name = 某tLine(;
veDevice(name);
break;
case 3:
system.displayDevices(;
break;
case 4:
scanner.close(;
System.e某it(0);
}
}
}
```
系统通过读取用户输入,提供菜单选项来执行相应的操作。用户可以选择添加设备,移除设备或显示所有设备。
使用此源代码,您可以开始构建Java设备管理系统,根据您的实际需求进行扩展和定制。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论