Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimsrod authored Dec 25, 2022
0 parents commit ec9be00
Show file tree
Hide file tree
Showing 19 changed files with 1,152 additions and 0 deletions.
11 changes: 11 additions & 0 deletions VapeStore/VapeStore.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
84 changes: 84 additions & 0 deletions VapeStore/src/VapeStore/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package VapeStore;

import java.util.Objects;
import java.util.Scanner;

public class Category {

private String catName, catDescription;
private Category catParent;

public Category() {
Scanner sc = new Scanner(System.in);
System.out.println("Saisir le nom de la catégorie : ");
this.catName = sc.nextLine();
System.out.println("Saisir la description de la catégorie : ");
this.catDescription = sc.nextLine();
this.catParent = null;
}

public Category(String catName, String catDescription, Category parentCat) {
this.catName = catName;
this.catDescription = catDescription;
this.catParent = parentCat;
}

//deep cloning
public Category(Category catCopy) {
this.catName = catCopy.catName;
this.catDescription = catCopy.catDescription;
this.catParent = catCopy.catParent;
}

public String getCatName() {
return catName;
}

public String getCatDescription() {
return catDescription;
}

public Category getCatParent() {
return catParent;
}

public void setCatParent(Category catParent) {
this.catParent = catParent;
}

//check on category name only
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Category category = (Category) o;
return Objects.equals(catName, category.catName);
}

@Override
public int hashCode() {
return Objects.hash(catName);
}

@Override
public String toString() {

return "Nom de la catégorie : " + catName + "\nDescription : " + catDescription;
}


public String saisie(String regex, String message) {
Scanner sc = new Scanner(System.in);
boolean check = false;
String phrase;
do {
phrase = sc.nextLine();
if (phrase.matches(regex)) {
check = true;
} else {
System.out.println(message);
}
} while (!check);
return phrase;
}
}
5 changes: 5 additions & 0 deletions VapeStore/src/VapeStore/DateValidator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package VapeStore;

public interface DateValidator {
boolean isValid(String dateStr);
}
30 changes: 30 additions & 0 deletions VapeStore/src/VapeStore/DateValidatorUsingDateTimeFormatter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package VapeStore;

import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;


public class DateValidatorUsingDateTimeFormatter implements DateValidator {
private DateTimeFormatter dateFormatter;

//https://www.baeldung.com/java-string-valid-date

//constructor , no attribute, takes the same pattern of the orders' dates
public DateValidatorUsingDateTimeFormatter(){
this.dateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
}

public DateValidatorUsingDateTimeFormatter(DateTimeFormatter dateFormatter) {
this.dateFormatter = dateFormatter;
}

@Override
public boolean isValid(String dateStr) {
try {
this.dateFormatter.parse(dateStr);
} catch (DateTimeParseException e) {
return false;
}
return true;
}
}
Loading

0 comments on commit ec9be00

Please sign in to comment.