Skip to content

Studio 9 7 2023 menu #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 52 additions & 15 deletions classes-part-2/studio/src/main/java/org/launchcode/Menu.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,69 @@
package org.launchcode;
import org.launchcode.MenuItem;

import java.util.ArrayList;
import java.util.Date;

//public class Menu {
// private Date lastUpdated;
// private ArrayList<MenuItem> items;
//
// public Menu(Date d, ArrayList<MenuItem> i) {
// this.lastUpdated = d;
// this.items = i;
// }
//
// public void setLastUpdated(Date lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
//
// public void setItems(ArrayList<MenuItem> items) {
// this.items = items;
// }
//
// public Date getLastUpdated() {
// return lastUpdated;
// }
//
// public ArrayList<MenuItem> getItems() {
// return items;
// }
//}





public class Menu {
private Date lastUpdated;
private ArrayList<MenuItem> items;

public Menu(Date d, ArrayList<MenuItem> i) {
this.lastUpdated = d;
this.items = i;
}

public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
public ArrayList<MenuItem> getItems() {
return items;
}

public void setItems(ArrayList<MenuItem> items) {
this.items = items;
}

public Date getLastUpdated() {
return lastUpdated;
}
public static void menuSetter(ArrayList){
for (Object menuItem:ArrayList){
if (category = "Apps") {
System.out.println(menuItem);
}

public ArrayList<MenuItem> getItems() {
return items;
}
}
}
for (Object menuItem:ArrayList) {
if (category = "Entrees") {
System.out.println(menuItem);
}
}

for (Object menuItem:ArrayList) {
if (category = "Desserts") {
System.out.println(menuItem);
}
}


}
}
98 changes: 84 additions & 14 deletions classes-part-2/studio/src/main/java/org/launchcode/MenuItem.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,102 @@
package org.launchcode;
import org.launchcode.Menu;
import java.util.ArrayList;

//public class MenuItem {
// private double price;
// private String description;
// private String category;
// private boolean isNew;
//
// public MenuItem(double p, String d, String c, boolean iN) {
// this.price = p;
// this.description = d;
// this.category = c;
// this.isNew = iN;
// }
//
// public void setPrice(double price) {
// this.price = price;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public void setCategory(String category) {
// this.category = category;
// }
//
// public void setNew(boolean aNew) {
// isNew = aNew;
// }
//}








public class MenuItem {
private double price;
private String description;
private String category;
private boolean isNew;
private String category;
private String itemName;
private Double price;
private String description;
private Boolean novelty = true;
// private ArrayList<Object> allMenuItems = new ArrayList <>();


public MenuItem(String category, String itemName, Double price, String description){
this.category = category;
this.itemName = itemName;
this.price = price;
this.description = description;
//allMenuItems.add(this);
}

public MenuItem(double p, String d, String c, boolean iN) {
this.price = p;
this.description = d;
this.category = c;
this.isNew = iN;
public String getCategory() {
return category;
}

public void setPrice(double price) {
public void setCategory(String category) {
this.category = category;
}

public String getItemName() {
return itemName;
}

public void setItemName(String itemName) {
this.itemName = itemName;
}

public Double getPrice() {
return price;
}

public void setPrice(Double price) {
this.price = price;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public void setCategory(String category) {
this.category = category;
public Boolean getNovelty() {
return novelty;
}

public void setNew(boolean aNew) {
isNew = aNew;
public void setNovelty(Boolean novelty) {
this.novelty = novelty;
}
}

//MenuItem wings = new MenuItem ("apps", "wings", 10, "lightly breaded and fried chicken wings served with sauces")
//MenuItem lambChops = new MenuItem ("entrees", "Lamb Chops", 28.35, "Rack of Lamb Chops in cilantro ginger marinade on a bed of shishieto peppers with chili honey glaze")
//MenuItem chocolateCake = new MenuItem ("desserts", "chocolate cake", 6.95, "A soft and tender Chocolate Fudge cake covered in a rich and creamy chocolate buttercream\n")
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.launchcode;

public class Main {

public class Restaurant {

public static void main(String[] args) {
// write your code here
Menu.menuSetter(allMenuItems);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.launchcode;
import java.util.Scanner;

public class Area {
public static void main(String[] args){
double radius;
double area;
Scanner input;
input = new Scanner(System.in);
System.out.println("Enter a radius.");
radius = input.nextDouble();
input.close();
if (radius > 0) {
area = Circle.getArea(radius);
System.out.println("The area of the circle with radius " + radius + " is " + area);
} else {
System.out.println("Error");

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.launchcode;

public class Circle {
public static Double getArea(Double radius) {
return 3.14 * radius * radius;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.launchcode;

import java.util.ArrayList;
import java.util.Date;

//public class Menu {
// private Date lastUpdated;
// private ArrayList<MenuItem> items;
//
// public Menu(Date d, ArrayList<MenuItem> i) {
// this.lastUpdated = d;
// this.items = i;
// }
//
// public void setLastUpdated(Date lastUpdated) {
// this.lastUpdated = lastUpdated;
// }
//
// public void setItems(ArrayList<MenuItem> items) {
// this.items = items;
// }
//
// public Date getLastUpdated() {
// return lastUpdated;
// }
//
// public ArrayList<MenuItem> getItems() {
// return items;
// }
//}





public class Menu {
private ArrayList<MenuItem> items;

public ArrayList<MenuItem> getItems() {
return items;
}

public void setItems(ArrayList<MenuItem> items) {
this.items = items;
}

public static void menuSetter(ArrayList){
for (Object menuItem:ArrayList){
if (category = "Apps") {
System.out.println(menuItem);
}

}
for (Object menuItem:ArrayList) {
if (category = "Entrees") {
System.out.println(menuItem);
}
}

for (Object menuItem:ArrayList) {
if (category = "Desserts") {
System.out.println(menuItem);
}
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,25 @@ public class BalancedBrackets {
* @param str - to be validated
* @return true if balanced, false otherwise
*/
// public static boolean hasBalancedBrackets(String str) {
// int brackets = 0;
// for (char ch : str.toCharArray()) {
// if (ch == '[') {
// brackets++;
// } else if (ch == ']') {
// brackets--;
// }
// }
// return brackets == 0;
// }
public static boolean hasBalancedBrackets(String str) {
int brackets = 0;
for (char ch : str.toCharArray()) {
if (ch == '[') {
if (str.indexOf(']') < str.indexOf('[')) {
return false;
} else if (str.lastIndexOf('[') > str.lastIndexOf(']') ){
return false;
}else if(ch == '[') {
brackets++;
} else if (ch == ']') {
brackets--;
Expand Down
Loading