behzad20020
22-02-2008, 10:29
سلام من تازه چند روزه کار با جاوا رو شروع کردم یه برنامه هست که یک کلاس تولید می کنه و تو main ازش استفاده می کنه اما اشکال داره
public class item {
private double unit_price ;
private double discount ;
private int tedad ;
private String tozih ;
private String id ;
public item(String id, String tozih, int tedad, double price ) {
this.id=id;
this.tozih=tozih;
if (tedad >=0) {
this.tedad=tedad;
}
else
{
this.tedad=0;
}
this.unit_price=unit_price;
}
public double getadjustedtotal();
{
double total = unit_price * tedad ;
double total_discount = total * discount ;
double gimat =total - total_discount ;
return gimat ;
}
public void setdiscount(double discount);
{
if (discount <=1)
{
this.discount=discount ;
}
else {
this.discuont = 0 ;
}
}
public double getdiscount() ;
{
return discount ;
}
public int gettedad();
{
return tedad ;
}
public void settedad(int tedad)
{ if (tedad>=o)
{this.tedad=tedad ;
}
}
public String getid();
{return id;
}
public String gettozih()
{
return tozih ;
}
( public static void main (String args[] ){
item shir = new item("shir","yaraneii",10,2500);
shir.setdiscount(0.01);
int gimat =shir.getadjustedtotal();
System.out.printf("%d",gimat) ;
}
}
public class item {
private double unit_price ;
private double discount ;
private int tedad ;
private String tozih ;
private String id ;
public item(String id, String tozih, int tedad, double price ) {
this.id=id;
this.tozih=tozih;
if (tedad >=0) {
this.tedad=tedad;
}
else
{
this.tedad=0;
}
this.unit_price=unit_price;
}
public double getadjustedtotal();
{
double total = unit_price * tedad ;
double total_discount = total * discount ;
double gimat =total - total_discount ;
return gimat ;
}
public void setdiscount(double discount);
{
if (discount <=1)
{
this.discount=discount ;
}
else {
this.discuont = 0 ;
}
}
public double getdiscount() ;
{
return discount ;
}
public int gettedad();
{
return tedad ;
}
public void settedad(int tedad)
{ if (tedad>=o)
{this.tedad=tedad ;
}
}
public String getid();
{return id;
}
public String gettozih()
{
return tozih ;
}
( public static void main (String args[] ){
item shir = new item("shir","yaraneii",10,2500);
shir.setdiscount(0.01);
int gimat =shir.getadjustedtotal();
System.out.printf("%d",gimat) ;
}
}