This is a simple basic program using Java to create objects to add all the necessary information about the new product.
Here, in this program, we will create a new object to add information such as price, quantity, shipped from, delivery address, expected delivery date, and mode of payment.
When an object is created the custom constructor is called at runtime which sets values for the instance variables.
To get the correct date format in the delivery date(instance variable), we have created a separate private function by creating a custom exception class that extends the 'Exception' class of Java.
NOTE: Date format should be in dd/MM/yyyy format only.
To check if the user has placed a return pickup or not a boolean function is created which returns a boolean value.
We have imported some classes - ParseException, SimpleDateFormat, LocalDate, Date, and Scanner.
Submitted by Satvik Singh Sengar (satviksinghsengar)
Download packets of source code on Coders Packet
Comments