(11-27-2013, 02:58 PM)blackeagle Wrote: @Deque ok thank you very much still have 1 more question on my mind if i have 3 classes is it possible to use the same method name inside the 3 classes !!
i.e:in first class
public void info(){
}
second class
public void info(){
super.info()
and i add something more}
i want to do this but netbeans tell me in the second class that the method already exist and i need to override it!!
if i do so i wont be able to use the first 1 ?
Yes, you can use methods with the same name in different classes.
But in your case--if Netbeans wants you to put an override annotation--you have used inheritance.
That means you inherit the method of the parent class and making another method with the same name means you override it (you create a new implementation).
You can still use the method of the parent class by using super.
I.e.
Code:
super.info() //calls method info() of the parent class
And if you want to use the method of your current class you just call
(11-28-2013, 12:39 AM)blackeagle Wrote: i was able to do this part !! i did everything and i guess everything is fine !!
Spoiler:
Code:
Write an application to manage the stock of a store.
Here is a specification of the program in terms of classes and interfaces:
interfaces
Salable per kilogram : the interface for selling items per kilogram
methods:
Sale : This method receives the quantity sold of the item and change the stock
Salable piece : the interface for items that sell by pieces
methods:
Sale : This method receives the number of rooms sold the item and change the stock
Likely to be sold in balance
methods:
start balance : This method lowers the price of the item by the given percentage
complete the balance : This method increases the price of the item by the given percentage
classes
Class Articles: general class of all items
Properties: number (automatically generated during the creation of an article) , purchase price , sale price and name.
Methods ( other than the manufacturer):
calculating the rate of return ( ( prixVente - prixAchat ) / prixAchat )
toString (): return the name and price of the item
This class does not implement any interface.
Two derived class Articles classes:
Class artciles Appliance
Aditional property : the number of items in stock
Additional methods ( other than the manufacturer):
Add a number of pieces in stock
toString (): return the name , the price of the item and the number of parts
You must implement the corresponding interfaces this class .
Class articles futures
Additional property : quantity in stock
Additional methods:
Add the stock quantity
toString (): return the name , the price of the item and the quantity in stock
You must implement the corresponding interfaces this class , knowing that the items futures can not be sold on sale.
now i have a new part
Spoiler:
Code:
class Store
Properties: a vector (Vector)
Methods (other than the manufacturer):
Add product to the vector
Save name, purchase price and selling price of all items in the futures vector "Primeurs.data" file properties
Save all items appliances (as instances) of the vector in the "Electro.data" file
Save the information generated by toString all items in the vector file "info.data"
Print file information "info.java"
Read "Primeurs.data" file and print the name and the performance of each primary article.
Read "Electro.data" file and print the number and performance of each article appliances.
can some1 give me and exemple n how to do this ? i know how to save to a file and read from a file i have it in a course thats not my problem but what i did here is :
Code:
import java.util.Vector;
public class Store {
Vector vecteur = new Vector();
public Store(){
vecteur=null;
}
public void addArticle(Article article){
vecteur.addElement(article);
}
i need to know how should i do this step: Save name, purchase price and selling price of all items in the futures vector "Primeurs.data" file properties
hope any1 can help
and i'm sry i feel like i'm a pain to every1 here 
I am not sure that I understand the task correctly.
Are you supposed to save the information (name, purchase price, selling price) in the vector or in the file? What are file properties for you?
I guess the translation is a bit akward.