Java“库存程序”救命 [英] Java "Inventory program" help

查看:79
本文介绍了Java“库存程序”救命的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手,在使程序正确编译时遇到问题。


我的作业如下:

选择适合库存的产品(例如,工作场所的产品,办公用品,音乐CD, DVD电影或软件)。

?创建一个产品类,其中包含项目编号,产品名称,库存单位数量以及每个单元的价格。

?创建一个Java应用程序,显示产品编号,产品名称,库存单位数,每个单元的价格以及库存值(库存中的单位数乘以每个单位的价格) 。请注意文本中的良好编程习惯,以确保您的源代码可读并且记录良好。


这是我到目前为止的内容

I am new to Java and am having problems getting my program to compile correctly.

My assignment is as follows;
Choose a product that lends itself to an inventory (for example, products at your workplace, office supplies, music CDs, DVD movies, or software).
? Create a product class that holds the item number, the name of the product, the number of units in stock, and the price of each unit.
? Create a Java application that displays the product number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory (the number of units in stock multiplied by the price of each unit). Pay attention to the good programming practices in the text to ensure your source code is readable and well documented.

Here is what I have so far

展开 | 选择 | Wrap | 行号

推荐答案

在您的代码中包含以下代码段。

public Dvd()

{


}


原因是当存在参数化构造函数时,编译器不提供默认构造函数。

另外

你不需要扩展你的课程对象类。

默认情况下会发生。



问候,

shailesh
include the following piece of code in your code.
public Dvd()
{


}

The reason for this is compiler does not supply default constructor when there are parameterised constructors.
Also
you need not extend your class with Object class.
It happens by default.



with regards,
shailesh


感谢指针。我删除了对象类的扩展名。


我不是故意在这里听起来很密集,但当我在我的代码中添加公共Dvd()和大括号时(最后,在打印声明之前),我得到了非法的表达错误开始。


是否有一个特定的地方我应该添加公共DVD()?


再次感谢。

Thanks for the pointers. I removed the extension for the object class.

I don''t mean to sound dense here, but when I added the public Dvd() and the braces in my code (at the end, before the print statments), I got a illegal start of expression error.

Is there a specific place that I should have added the public DVD() in?

Thanks again.


在您的代码中包含以下代码。

public Dvd()

{$ / $

}


原因是当存在参数化构造函数时,编译器不提供默认构造函数。

另外

您不需要使用Object类扩展您的类。

默认情况下会发生。




问候,

shailesh
include the following piece of code in your code.
public Dvd()
{


}

The reason for this is compiler does not supply default constructor when there are parameterised constructors.
Also
you need not extend your class with Object class.
It happens by default.



with regards,
shailesh



谢谢你的指点。我删除了对象类的扩展名。


我不是故意在这里听起来很密集,但当我在我的代码中添加公共Dvd()和大括号时(最后,在打印声明之前),我得到了非法的表达错误开始。


是否有一个特定的地方我应该添加公共DVD()?


再次感谢。
Thanks for the pointers. I removed the extension for the object class.

I don''t mean to sound dense here, but when I added the public Dvd() and the braces in my code (at the end, before the print statments), I got a illegal start of expression error.

Is there a specific place that I should have added the public DVD() in?

Thanks again.



你不需要添加一个no-args构造函数Dvd();第90行的错误被提升

,因为你没有一个需要四个字符串的Dvd构造函数。仔细阅读

错误信息,你会发现这正是编译器

试图告诉你的。


你有一个Dvd构造函数,需要一个字符串和三个双精度数。那个

应该响铃。


你得到的新错误是因为大括号不匹配。


亲切的问候,


Jos

You don''t need to add a no-args constructor Dvd(); the error at line 90 is raised
because you don''t have a Dvd constructor that takes four Strings. Read that
error message carefully and you''ll see that this is exactly what the compiler
is trying to tell you.

You do have a Dvd constructor that takes one string and three doubles. That
should ring a bell.

The new errors you got is because of mismatched curly brackets.

kind regards,

Jos


这篇关于Java“库存程序”救命的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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