From 94b49a40268027eb71a2bf4d2dbb5c3f47d731e0 Mon Sep 17 00:00:00 2001 From: James O'Rourke Date: Thu, 28 Dec 2017 14:25:30 +0000 Subject: [PATCH 1/4] +back to this then --- src/project/ActorList.java | 2 +- src/project/Main.java | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/project/ActorList.java b/src/project/ActorList.java index 7fb2104..bbc7fe7 100644 --- a/src/project/ActorList.java +++ b/src/project/ActorList.java @@ -22,7 +22,7 @@ public static void addActor(String name, int age, String gender, String national Actor newActor = new Actor(name, age, gender, nationality, genre); int index = age; int hash = index % hashlist.length; - LinkedList hashedList = hashlist[name.hashCode()]; + LinkedList hashedList = hashlist[index]; if(hashedList == null) hashedList = new LinkedList(); hashedList.add(newActor); diff --git a/src/project/Main.java b/src/project/Main.java index 9e5ddeb..b663766 100644 --- a/src/project/Main.java +++ b/src/project/Main.java @@ -1,19 +1,21 @@ package project; -/*public class Main{ +public class Main { public static void main(String[] args) { Main test = new Main(); } - public Main(){ - IODriver app = new IODriver(); + public Main() { + IODriver app = new IODriver(); - }*/ + } +} +/* @@ -79,6 +81,7 @@ public static void main(String[] args) { launch(args); } } +*/ From 3fddbc88f7eb0ba35879507f16ce67eeffdd5931 Mon Sep 17 00:00:00 2001 From: James O'Rourke Date: Thu, 28 Dec 2017 22:24:06 +0000 Subject: [PATCH 2/4] +nothing much --- src/project/Actor.java | 14 ++++----- src/project/Controller.java | 11 +++++++ src/project/IODriver.java | 59 ++++++++++++++++++++++++++++++++----- src/project/Main.java | 23 +++++++++------ src/project/sample.fxml | 6 ++-- 5 files changed, 84 insertions(+), 29 deletions(-) diff --git a/src/project/Actor.java b/src/project/Actor.java index d03245d..6c3f488 100644 --- a/src/project/Actor.java +++ b/src/project/Actor.java @@ -10,7 +10,7 @@ public class Actor { private int age; private String gender; private String nationality; - private LinkedList genre; // list of genres so we can make a drop down in javafx | genre they star in maybe + // constructor public Actor(String name,int age, String gender, String nationality, LinkedList genre) { @@ -18,7 +18,7 @@ public Actor(String name,int age, String gender, String nationality, LinkedList this.age = age; this.gender = gender; this.nationality = nationality; - this.genre = genre; + } @@ -55,17 +55,13 @@ public void setNationality(String nationality) { this.nationality = nationality; } - public LinkedList getGenre() { - return genre; - } - public void setGenre(LinkedList genre) { - this.genre = genre; - } + + @Override public String toString() { - String str = "Actor info:[name:"+getName() +", "+"age:"+getAge()+", "+"gender: "+getGender()+", "+"nationality: "+getNationality()+", "+"genre=" + getGenre()+"] \n"; + String str = "Actor info:[name:"+getName() +", "+"age:"+getAge()+", "+"gender: "+getGender()+", "+"nationality: "+getNationality()+"] \n"; return str; } diff --git a/src/project/Controller.java b/src/project/Controller.java index 8278aa1..dd63f95 100644 --- a/src/project/Controller.java +++ b/src/project/Controller.java @@ -8,6 +8,7 @@ import javafx.scene.input.MouseEvent; public class Controller implements EventHandler{ + IODriver test = new IODriver(); @FXML private Label exit; @@ -22,6 +23,16 @@ private void handleClose(MouseEvent event) { public void handle(ActionEvent event){ } + @FXML + public void test() + { + System.out.println("test"); + test.fillArray(49); + test.setupAdditions(30); + + } + + } diff --git a/src/project/IODriver.java b/src/project/IODriver.java index 174487c..3ff46c2 100644 --- a/src/project/IODriver.java +++ b/src/project/IODriver.java @@ -36,6 +36,10 @@ private void homeMenu() { addMenu(); break; case "s": + searchMenu(); + break; + case "q": + fillArray(49); setupAdditions(30); break; case "t": @@ -63,6 +67,7 @@ private String home() { System.out.println("__________________"); System.out.println("¦ Add(a) ¦"); System.out.println("¦ Search(s) ¦"); + System.out.println("¦ initilize(q) ¦"); System.out.println("__________________"); System.out.println(" --------- "); System.out.println(" e) Exit"); @@ -85,8 +90,6 @@ private String add() { System.out.println("¦ print listm(l) ¦"); System.out.println("¦ print listh(h) ¦"); System.out.println("¦ show array(b) ¦"); - System.out.println("¦ Fill MovieArray(f)¦"); - System.out.println("¦ Fill ActorArray(l)¦"); System.out.println("¦ Go Back(g) ¦"); System.out.println("____________________"); System.out.println(" --------- "); @@ -117,10 +120,6 @@ private void addMenu() { case "b": showArray(50); break; - case "f": - fillArray(49); - setupAdditions(30); - break; case "g": homeMenu(); break; @@ -148,7 +147,7 @@ private void showArray(int amount){ } - private void fillArray(int amount){ + protected void fillArray(int amount){ for (int i = 0; i <= amount; i++) MovieList.hashlist[i] = new LinkedList<>(); @@ -173,6 +172,50 @@ private void addMovie() { MovieList.addMovie(title, year,runningTime,plot,imgUrl); } + private String search() { + System.out.println("Search Menu"); + System.out.println("What do you want to Search?"); + System.out.println("___________________"); + System.out.println("¦ Movie(m) ¦"); + System.out.println("¦ Go Back(g) ¦"); + System.out.println("____________________"); + System.out.println(" --------- "); + System.out.println(" e) Exit"); + System.out.print("==>> "); + String option = input.next(); + option = option.toLowerCase(); + return option; + } + + private void searchMenu() { + String option = search(); + while (!option.equals("e")) { + + switch (option) { + case "m": + runt(); + break; + case "g": + homeMenu(); + break; + default: + System.out.println("Invalid option entered: " + option); + break; + } + + // pause the program so that the user can read what was just printed + // to the terminal window + System.out.println("\nPress Return to continue..."); + input.nextLine(); + input.nextLine(); + + option = search(); + } + exitApp(); + + } + + private void addActor(){ input.nextLine(); System.out.print("what is the title of the movie?"); @@ -235,7 +278,7 @@ public void listm(int runtime){ } */ - private void setupAdditions(int amount){ + protected void setupAdditions(int amount){ for (int i = 1; i!= amount; i++){ diff --git a/src/project/Main.java b/src/project/Main.java index b663766..ffc7571 100644 --- a/src/project/Main.java +++ b/src/project/Main.java @@ -1,6 +1,5 @@ package project; - public class Main { public static void main(String[] args) { @@ -49,26 +48,32 @@ public class Main extends Application { private double xOffset = 0; private double yOffset = 0; + @Override public void start(Stage stage) throws Exception{ + + Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); - stage.initStyle(StageStyle.UNDECORATED); - root.setOnMousePressed(new EventHandler() { + stage.initStyle(StageStyle.UNDECORATED); + root.setOnMousePressed(new EventHandler() { @Override public void handle(MouseEvent event) { xOffset = event.getSceneX(); yOffset = event.getSceneY(); - } - }); + } + }); - root.setOnMouseDragged(new EventHandler() { + root.setOnMouseDragged(new EventHandler() { @Override public void handle(MouseEvent event) { stage.setX(event.getScreenX() - xOffset); stage.setY(event.getScreenY() - yOffset); - } - }); + } + }); + + + Scene scene1 = new Scene(root); @@ -81,8 +86,8 @@ public static void main(String[] args) { launch(args); } } -*/ +*/ diff --git a/src/project/sample.fxml b/src/project/sample.fxml index 86f50ac..1f6dc76 100644 --- a/src/project/sample.fxml +++ b/src/project/sample.fxml @@ -14,14 +14,14 @@ -