Untitled

 avatar
unknown
java
4 years ago
2.1 kB
14
Indexable
package com.cuadong;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class PRODUCT {
	private String ID;
	private String Name;
	private float Price;
	private Date MgfDate;
	private Date ExpDate;
	
	public String getID(){
		return this.ID;
	}
	public void setID(String ID) {
		this.ID = ID;
	}
	
	public String getName() {
		return this.Name;
	}
	public void setName(String Name) {
		this.Name = Name;
	}
	
	public float getPrice() {
		return this.Price;
	}
	public void setPrice(float Price) {
		this.Price = Price;
	}
	
	public Date getMgfDate() {
		return this.MgfDate;
	}
	public void setMgfDate(Date MgfDate) {
		this.MgfDate = MgfDate;
	}
	
	public Date getExpDate() {
		return this.ExpDate;
	}
	public void setExpDate(Date ExpDate) {
		this.ExpDate = ExpDate;
	}
	
	public PRODUCT() {}
	public PRODUCT(String ID, String Name) {
		this.ID = ID;
		this.Name = Name;
	}
	
	public void InputProduct(){
		Scanner scanner = new Scanner(System.in);
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		
		System.out.print("Enter ID: ");
		this.ID = scanner.nextLine();
		
		System.out.print("Enter Name: ");
		this.Name = scanner.nextLine();
		
		System.out.print("Enter Price: ");
		this.Price = Float.parseFloat(scanner.nextLine());
		
		System.out.print("Enter MGF Date: ");
		try {
			this.MgfDate = sdf.parse(scanner.nextLine());
			
		} catch (ParseException e) {
			
		}
		
		System.out.print("Enter EXP Date: ");
		try {
			this.ExpDate = sdf.parse(scanner.nextLine());
			
		} catch (ParseException e) {
			
		}
		
		scanner.close();
	}
	public void ShowProduct() {
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		
		System.out.println("ID: " + this.ID);
		System.out.println("Name: " + this.Name);
		System.out.println("Price: " + this.Price);
		System.out.println("MGF Date: " + sdf.format(this.MgfDate));
		System.out.println("EXP Date: " + sdf.format(this.ExpDate));
	}
}
Editor is loading...