JAVA PROGRAM
i created the program but the program i made is lacking in basic things and it is giving me many error. Please help me in correcting the program and making my concept clear. Do suggest how can i make this program more modified too.
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
@simplycoder-NsBEdD • Oct 8, 2012
Have you posted the correct code? I havent seen it entirely, however the basic mistakes I can see are syntactical. Please refer any basic book on java and correct them.zioncreate a class medicine.provide a function displaylabel() in this class to print name and address of the company. Derive tablet,syrup and oinment classes from the medicine class.Override the display label() function in each of these classes to print additional information suitable to the type of medicine..for eg in case of tablet ,it could be "store in a cool place, in case of ointment it could be "for external use only" etc. Create a class testmedicinee ,which will contain main function. Create object of each class in test medicinee.
i created the program but the program i made is lacking in basic things and it is giving me many error. Please help me in correcting the program and making my concept clear. Do suggest how can i make this program more modified too.
@anoop-kumar-GDGRCn • Oct 8, 2012
class Medicine {
String name;
String address;
void displayLabel() {
name = "zion medical store";
address = "India";
System.out.println(name +" "+ address);
}
}
class Tablet extends Medicine {
void displayLabel() {
System.out.println("store in cool n dry place");
}
}
class Syrup extends Medicine {
void displayLabel() {
System.out.println("take after taking eatables");
}
}
class Ointment extends Medicine {
void displayLabel() {
System.out.println("for external use only");
}
}
public class Testmedicine {
public static void main(String args[]) {
Medicine obj2 = new Medicine();
obj2.displayLabel();
Tablet obj0 = new Tablet();
obj0.displayLabel();
Syrup obj1 = new Syrup();
obj1.displayLabel();
Ointment obj3 = new Ointment();
obj3.displayLabel();
}
}
In last: first try to master Object Oriented Concepts.@zion-6KgmEO • Oct 9, 2012