|
-
Oct 30th, 2001, 03:29 PM
#1
Thread Starter
Fanatic Member
arrghhh this is right or is it ??
well, it looks alright to me
Code:
/** this is the main program to be run and it is called Shop
*/
import Supplier;
import Product;
public class Shop {
public static void main(String args[])
{
/**here is where i will put in all of the information about the suppliers, once i have done this i will do the same for the products */
Supplier Supplier1 = new Supplier ("Bobbies Suppliers", "6 Oak Street, Aberystwyth", 123654, 123655);
Supplier Supplier2 = new Supplier ("Franks Fruits", "32 Flan Street, Newtown Road, Aberystwyth", 112233, 112244);
Supplier Supplier3 = new Supplier ("Dai, What Big Veg", "43 Hereford Close, Somersham, Hunts", 823894, 823456);
Supplier Supplier4 = new Supplier ("Aubreys Fruit and Veg", "25a Parkhall Road, Somersham, Hunts", 223354, 223356);
Supplier Supplier5 = new Supplier ("JVC Veggies", "27 Slade Close, Ramsey, Hunts", 998764, 998763);
Product Prod1 = new Product ("Carrots", "0.30", "Each");
Product Prod2 = new Product ("Potatoes", "2.00", "Per Bag");
Product Prod3 = new Product ("Apples", "0.28", "Per Lbs");
Product Prod4 = new Product ("Oranges", "0.20", "Each");
/** This is where all of the information is being joined together and printed on the screen, man i am getting hungry now, might get something to east soon ;) */
System.out.println ("This is the Shop Demo");
System.out.println ("\nThe name of the first supplier is - " + Supplier1.getTheName() + " ,\nand their address is - " + Supplier1.getTheAddress() + " ,\nand their phone number is - " + Supplier1.getThePhone() + " ,\nand their fax number is - " + Supplier1.getTheFax() + " .");
System.out.println ("\n\nThe name of the second supplier is - " + Supplier2.getTheName() + " ,\nand their address is - " + Supplier2.getTheAddress() + " ,\nand their phone number is - " + Supplier2.getThePhone() + " ,\nand their fax number is - " + Supplier2.getTheFax() + " .");
System.out.println ("\n\nThe name of the third supplier is - " + Supplier3.getTheName() + " ,\nand their address is - " + Supplier3.getTheAddress() + " ,\nand their phone number is - " + Supplier3.getThePhone() + " ,\nand their fax number is - " + Supplier3.getTheFax() + " .");
System.out.println ("\n\nThe name of the fourth supplier is - " + Supplier4.getTheName() + " ,\nand their address is - " + Supplier4.getTheAddress() + " ,\nand their phone number is - " + Supplier4.getThePhone() + " ,\nand their fax number is - " + Supplier4.getTheFax() + " .");
System.out.println ("\n\nThe name of the fifth supplier is - " + Supplier5.getTheName() + " ,\nand their address is - " + Supplier5.getTheAddress() + " ,\nand their phone number is - " + Supplier5.getThePhone() + " ,\nand their fax number is - " + Supplier5.getTheFax() + " .");
System.out.println ("\n\n The first product is - " + Prod1.itemName() + "\n It is £" + Prod1.theCost() + " " + Prod1.theUnitSale() + ".");
// need to join these supplier to food at some point
}
}
but for some reason on the Product part, it says that it can't resolve the "n" on the keyword new when i go to compile it, any ideas, and i think that i have got all of the capitals sorted out this time 
please help
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Oct 31st, 2001, 06:14 AM
#2
Thread Starter
Fanatic Member
After lots of buggering about, i managed to get some of it to work, though i would still appreciate a little explanation as to why i got that error,
but i feel that my best trick so far is that i managed to use the int thing to display a value like this
i know that it is a whole number but i didn't think that integers used decimal places
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 2nd, 2001, 03:21 AM
#3
Lively Member
Post the code for Supplier and Product and I will try to help you
-
Nov 2nd, 2001, 05:51 AM
#4
Thread Starter
Fanatic Member
ok then cheers, here is the code for the Supplier
Code:
public class Supplier {
public String name; // the name of the supplier
public String address; // the address of the supplier
public long phone; //the phone number of the supplier
public long fax; //the fax number of the supplier
/**
*this is the constructor method
*@param String name, this is the name of the supplier, and it is a text string
*@param String address, this is the address of the supplier of the product, and it is a text string
*@param long phone, this is the phone number of the supplier, it is a integer
*@param long fax, this is the fax number of the supplier, is it an integer
*/
public Supplier(String getName, String getAddress, long getPhone, long getFax)
/**
*setting the instance variables
*/
{
name = getName;
address = getAddress;
phone = getPhone;
fax = getFax;
}
public String getTheName()
{
return name;
}
public String getTheAddress()
{
return address;
}
public long getThePhone()
{
return phone;
}
public long getTheFax()
{
return fax;
}
}
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 2nd, 2001, 05:53 AM
#5
Thread Starter
Fanatic Member
and here is the code for the product
Code:
public class Product
{
public String nameItem; // Name of the item
public int cost; // Cost of item
public String unitSale; // Unit of sale for the item - ie - per pound, per bag etc...
//public String suppRef; // Reference to the Supplier
/**
* This is the constructor method for this class...
**/
public Product (String nameOfItem, int costOfItem, String unitOfSale) // String supplierReference
{
nameItem = nameOfItem;
cost = costOfItem;
unitSale = unitOfSale;
//suppRef = supplierReference;
}
// Begin actual methods...
// This method provides information about the Name of the Item...
public String itemName()
{
return nameItem;
}
// This method provides information about the Cost of an Item...
public int theCost()
{
return cost;
}
// This method provides information about the Unit Of Sale for an Item...
public String theUnitSale()
{
return unitSale;
}
// This method provides information about the Supplier...
//public String theSupplierReference()
//{
//return suppRef;
//}
}
thank you for your time and help with this matter
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 2nd, 2001, 06:18 AM
#6
Lively Member
In the product you have to change the cost to a double:
and you have to call it as a double
"Product Prod1 = new Product ("Carrots", 1.2, "Each");"
cost vithout the " "
-
Nov 2nd, 2001, 06:26 AM
#7
Thread Starter
Fanatic Member
as strange as it sounds i did originally have them set to doubles and there also were no quotes and it still went a little pear shapped, so any other ideas ??
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 2nd, 2001, 06:42 AM
#8
Lively Member
What is the error, it works fine by me
-
Nov 2nd, 2001, 06:53 AM
#9
Thread Starter
Fanatic Member
The error that i am getting is on the Product part, it says that it can't resolve the "n" on the keyword new when i go to compile it, and i think that i have got all of the capitals sorted out this time
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 2nd, 2001, 07:06 AM
#10
Lively Member
Before I make changes to the Product class, I got the same Error, but now it works fine by me.
public class Product
{
public String nameItem; // Name of the item
public double cost; // Cost of item
public String unitSale; // Unit of sale for the item - ie - per pound, per bag etc...
//public String suppRef; // Reference to the Supplier
/**
* This is the constructor method for this class...
**/
public Product (String nameOfItem, double costOfItem, String unitOfSale) // String supplierReference
{
nameItem = nameOfItem;
cost = costOfItem;
unitSale = unitOfSale;
//suppRef = supplierReference;
}
// Begin actual methods...
// This method provides information about the Name of the Item...
public String itemName()
{
return nameItem;
}
// This method provides information about the Cost of an Item...
public double theCost()
{
return cost;
}
// This method provides information about the Unit Of Sale for an Item...
public String theUnitSale()
{
return unitSale;
}
// This method provides information about the Supplier...
//public String theSupplierReference()
//{
//return suppRef;
//}
}
-
Nov 2nd, 2001, 07:20 AM
#11
Thread Starter
Fanatic Member
so all you did was change the value back to double, and took the quotes off and it works now ???
very strange
thanks i will try it again then
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 2nd, 2001, 07:25 AM
#12
Thread Starter
Fanatic Member
yeah it works now, not sure why it didn't to start with, perhaps you have some sort of magic touch 
just one more question, it doesn't display the £ sign instead i get ú
but i thought that if i did this
Code:
System.out.println("The product is £ ");
it would work but it doesn't
how do i implement the char keyword in it ??
sorry about all of the questions it is just that i have only been learning java for two weeks 
thanks again
Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had.
-- Linus Torvalds
[ Galahtech.com] | [ My Site] | [ Fishsponge] | [ UnixForum.co.uk]
-
Nov 2nd, 2001, 07:56 AM
#13
Lively Member
It must be something with your carakterset in the OS
I am running Windows 2000 Prof UK version and it works with DK and UK keyboard setting
(i got the £)
-
Nov 2nd, 2001, 07:59 AM
#14
Lively Member
By the way!
I have the same problem with all special car. if i run at the Command prompt, maby sombody else can help her.
I use KAWA 5.0 and here you have a output box and all are displayed well
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|