السلام عليكم
لدي واجب يجب أن أحله وهذا نص السؤال:
II) Design and implement selected parts of a simple inventory control system using the following specifications.
1) Implement a class to represent the information about each part in the inventory. Each part (for now – this might change for later assignments) has only three pieces of information associated with it: an ID (a string), a description (a string with potentially more than one word), and the quantity in stock. You must provide the following public interface:
a) Set and Get methods for each of these three pieces of information
B) A no-argument constructor which initializes a part’s ID to “0000”, its description to “No part information”, and its quantity to 0.
c) A constructor with three parameters (one for ID, one for description, and one for quantity), which initializes the ID, description, and quantity to the three parameters passed to it.
d) A display method which prints the part information to the screen in one line.
محاولتي هي:
public class inventory {
protected String ID;
protected String Description;
protected String Quantity;
// Constructor
public inventory(String newID,String newDescription,String newQuantity)
{
ID=newID;
Description=newDescription;
Quantity=newQuantity;
}
// Set and Get Methods
public String getID()
{
return ID;
}
public void setID(String newID)
{
ID=newID;
}
public String getDescription()
{
return Description;
}
public void setDescription(String newDescription)
{
Description=newDescription;
}
public String getQuantity()
{
return Quantity;
}
public void setQuantity(String newQuantity)
{
Quantity=newQuantity;
}
}بالنسبة للفقرة d قد تكون هي الأسهل لكن لم أعرف أين أضع الميثود.
هل الكود صحيح ام هناك أخطاء فيه أرجو الإطلاع والمساعدة.
كل الشكر