Java 自动清点程序-文件输出和捕获int索引存在问题
您的程序应具有适当的方法,例如:Java 自动清点程序-文件输出和捕获int索引存在问题,java,Java,您的程序应具有适当的方法,例如: private string make private string model private string color private int year private int mileage. 所有方法都应该包含try..catch构造。除非另有说明,否则所有方法都应返回catch中定义的成功或失败消息failure message 创建一个附加类来调用汽车类,例如Main或AutomobileInventory。包含try..catch构造并在出现任何
private string make
private string model
private string color
private int year
private int mileage.
所有方法都应该包含try..catch构造。除非另有说明,否则所有方法都应返回catch中定义的成功或失败消息failure message
创建一个附加类来调用汽车类,例如Main或AutomobileInventory。包含try..catch构造并在出现任何错误时将其打印到控制台
使用参数化构造函数调用automobile类,例如品牌、型号、颜色、年份、里程
然后调用该方法列出值。在阵列中循环并打印到屏幕上。
调用remove vehicle方法以清除变量
打印返回值。
添加一辆新车
打印返回值。
调用列表方法并将新车辆信息打印到屏幕上。
更新车辆
打印返回值。
调用listing方法并将信息打印到屏幕上。
显示一条消息,询问用户是否要将信息打印到文件Y或N
使用扫描仪捕获响应。如果是,则将文件打印到预定义位置,例如C:\Temp\Autos.txt。注意:您可能需要创建一个方法来打印主类中的信息。
如果为N,则表示将不打印文件。
我的程序在某种程度上符合我的要求,直到我尝试将索引号分配给用户输入的车辆,以便在以后进行更新或删除。这不会在输出中返回,在.txt文件中返回的只是标题和我的软件包,没有车辆。任何建议或帮助都会很好 索引参数为原始int数据类型
For int use=用于比较
default constructor
parameterized constructor
add a new vehicle method
list vehicle information (return string array)
remove a vehicle method
update vehicle attributes method.
欢迎来到stackoverflow。你问题中的一些细节似乎与你所遇到的问题无关。请尽可能具体。对于您遇到的问题,在将结果写入文件之前,请将这些结果写入控制台,以确保您试图写入文件的内容实际上正在写入。很抱歉,我正在仔细研究这个问题。贾加德什的建议是我一直在寻找的,我无意中忽略了这一点。我的程序输出和其他功能现在都正常工作了,我唯一要做的就是将程序链接到output.txt文件,在这个文件中,我的列表是由它生成的。
default constructor
parameterized constructor
add a new vehicle method
list vehicle information (return string array)
remove a vehicle method
update vehicle attributes method.
if (a1.getMake().equalsIgnoreCase(make) && a1.getModel().equalsIgnoreCase(model)
&& a1.getIndex() == index) {}