Write a program that meets the following requirements:
Sandwich Class
- ingredients (an array of up to 10 ingredients, such as ham, capicola, American cheese, lettuce, tomato)
-condiments (an array of up to 5 condiments, such as mayonnaise, oil, vinegar and mustard)
There should be NO main method in the Sandwich class.
SandwichMaker Class
If you have any doubts, please give me comment...
import java.util.Arrays;
public class Sandwich{
private String ingredients[];
private String condiments[];
public Sandwich(String ingredients[], String condiments[]){
this.ingredients = ingredients;
this.condiments = condiments;
}
/**
* @param ingredients the ingredients to set
*/
public void setIngredients(String[] ingredients) {
this.ingredients = ingredients;
}
/**
* @param condiments the condiments to set
*/
public void setCondiments(String[] condiments) {
this.condiments = condiments;
}
/**
* @return the ingredients
*/
public String[] getIngredients() {
return ingredients;
}
/**
* @return the condiments
*/
public String[] getCondiments() {
return condiments;
}
public String toString(){
return "Ingredients: "+Arrays.toString(ingredients)+"\nCondiments: "+Arrays.toString(condiments);
}
}
public class SandwichMaker{
public static void main(String[] args) {
Sandwich sandwiches[] = new Sandwich[5];
String ingredients1[] = {"ham", "capicola", "American cheese", "lettuce", "tomato"};
String condiments1[] = {"mayonnaise", "oil", "vinegar", "mustard"};
sandwiches[0] = new Sandwich(ingredients1, condiments1);
String ingredients2[] = {"ham", "capicola", "American cheese"};
String condiments2[] = {"mayonnaise", "oil", "vinegar"};
sandwiches[1] = new Sandwich(ingredients2, condiments2);
sandwiches[2] = new Sandwich(ingredients1, condiments2);
sandwiches[3] = new Sandwich(ingredients2, condiments2);
sandwiches[4] = new Sandwich(ingredients1, condiments2);
for(int i=0; i<sandwiches.length; i++){
System.out.println(sandwiches[i]);
}
}
}
Write a program that meets the following requirements: Sandwich Class Create a class called Sandwich which has the following instance variables. No other instance variables should be used: - ingredi...
Need help to create general
class
Classes Data Element - Ticket Create an abstract class called Ticket with: two abstract methods called calculateTicketPrice which returns a double and getld0 which returns an int instance variables (one of them is an object of the enumerated type Format) which are common to all the subclasses of Ticket toString method, getters and setters and at least 2 constructors, one of the constructors must be the default (no-arg) constructor. . Data Element - subclasses...
Course, Schedule, and ScheduleTester (100%) Write a JAVA program that meets the following requirements: Course Class Create a class called Course. It will not have a main method; it is a business class. Put in your documentation comments at the top. Be sure to include your name. Course must have the following instance variables named as shown in the table: Variable name Description crn A unique number given each semester to a section (stands for Course Registration Number) subject A...
Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram) Author -name:String -email:String -gender:char +Author(name:String, email:String, gender:char) +getName():String +getEmail):String +setEmail (email:String):void +getGender():char +tostring ):String . Three private instance variables: name (String), email (String), and gender (char of either 'm' or 'f'): One constructor to initialize the name, email and gender with the given values . Getters and setters: get Name (), getEmail() and getGender (). There are no setters for name and...
In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....
Course Class Create a class called Course. It will not have a main method; it is a business class. Put in your documentation comments at the top. Be sure to include your name. Course must have the following instance variables named as shown in the table: Variable name Description crn A unique number given each semester to a section (stands for Course Registration Number) subject A 4-letter abbreviation for the course (e.g., ITEC, PHED, CHEM) number A 4-digit number associated...
Create a class called Retangle.java that contains two double-precision instance variables named width and height. The class should include all kinds of overloaded constructors. Additionally, there should be two accessor methods, mutator methods, class method named area() that returns the area of a Rectangle object. Inside main(),fully test all methods.
Ticket Hierarchy Ticket Abstract Class Create a static variable called nextTicketId. This is an integer representing the next available integer for the ticketId private static int nextTicketId = 1000; getPrice method: Abstract method that returns a double. NOTE: Do not make price an instance variable in Ticket. Noargument constructor: Sets event name to “none”, event location to “none”, and ticket id to 0. Create a constructor that accepts the event name and event location as parameters. Set the ticket Id...
In c++ Write a program that contains a class called Player. This class should contain two member variables: name, score. Here are the specifications: You should write get/set methods for all member variables. You should write a default constructor initializes the member variables to appropriate default values. Create an instance of Player in main. You should set the values on the instance and then print them out on the console. In Main Declare a variable that can hold a dynamcially...
Programming Assignment 1 Write a class called Clock. Your class should have 3 instance variables, one for the hour, one for the minute and one for the second. Your class should have the following methods: A default constructor that takes no parameters (make sure this constructor assigns values to the instance variables) A constructor that takes 3 parameters, one for each instance variable A mutator method called setHour which takes a single integer parameter. This method sets the value of...
IN JAVA For the following questions, “define a class” means the following: • Create an appropriately-named file containing the Java class definition, including the following: – A block comment describing the file (and hence the class), as always – Any instance variables, as required by the question – Accessor (getter) and mutator (setter) methods for any instance variables – Constructors as appropriate or as required by the question – A toString method that prints instances of the class informatively –...