F
Funitra der SuperStier
Gast
Hallo,
folgendes Prog hat fehler im Konstruktor von Comic , und findet selbiges nicht. Auserdem findet es die Hashtable factorcondition nicht .
NAch 2 1/2 stündigem Aufregens , das Java Buch flog schon gegen die Wand , dachte ich mir bevor ich in die Tastatur beis und meinen Monitor gegen die Wand schmeis , mach ich ma einen Thread auf .
ich bedanke mich im voraus für jede Unterstützung
folgendes Prog hat fehler im Konstruktor von Comic , und findet selbiges nicht. Auserdem findet es die Hashtable factorcondition nicht .
NAch 2 1/2 stündigem Aufregens , das Java Buch flog schon gegen die Wand , dachte ich mir bevor ich in die Tastatur beis und meinen Monitor gegen die Wand schmeis , mach ich ma einen Thread auf .
Code:
import java.util.*;
class Comic{
String title;
String condition;
float baseprice;
float realprice;
Comic(String intitle,String incondition,float inbaseprice){
title = intitle;
condition = incondition;
baseprice = inbaseprice;
}
void setPrice(float factor){
realprice = baseprice * factor;
}
}
class ComicCollection{
public static void main (String[] arguments){
Hashtable factorcondition = new Hashtable();
float price1 = 3F;
factorcondition.put("mint",price1);
float price2 = 2F;
factorcondition.put("near mint",price2);
float price3 = 1.5F;
factorcondition.put("very fine",price3);
float price4 = 1F;
factorcondition.put("fine",price4);
float price5 = 0.75F;
factorcondition.put("good",price5);
float price6 = 0.5F;
factorcondition.put("poor",price6);
Comic[] comix = new Comic [3];
comix[0]=new Comic("Spiderman","good",25.4);
comix[1]=new Comic("Hulk","fine",50);
comix[2] = new Comic ("The Fantastic Four","poor",20);
for (int i = 0 ; i < comix.length; i++){
comix[i].setPrice(Float(factorcondition.get(comix[i].condition)));
}
ausgabe();
}
static void ausgabe(){
for (int i = 0 ; i < comix.length ; i++){
System.out.println(comix[i].title+" "+ comix[i].condition+" "+comix[i].baseprice+" "+comix[i].realprice);
}
}
}
ich bedanke mich im voraus für jede Unterstützung