In this question, we will bake a class. Create a class Cake, with the following instance attributes: • name (a string) • ingreds (a list of strings) • price (a float) The Cake class has also the following methods: • Write a constructor that takes as input a string indicating the cake name, and a list of strings indicating the cake ingredients. (No docstring needed.) The constructor uses these values to initialize the attributes accordingly. Note that each cake should be assigned a random price between $10.00 (inclusive) and $15.00 (exclusive). You may import random. Moreover, a cake must contain at least three or more ingredients. If this is not the case, the constructor should raise a ValueError. For this constructor, do not worry about making a copy of the input array. You can simply copy the reference received as input into the corresponding attribute. 1.
Q: Lab10B: My dog can do tricks For this lab we once again are going to create 2 classes, 1 called Dog…
A: import java.util.Scanner;class Dog{ // Data Members public int age; public double weight;…
Q: Please write the Java code for a Phone class that represents a mobile phone
A: 1. Create class phone declare all data member make , model,color and cpaciry define one constructor…
Q: Write the Boat class in Java Eclipse. A Boat has a registered name, a number of cabins, and a…
A: I give the code in Java eclipse as per your requirement along with code and output screenshot
Q: When you print an instance of the class Food in Question 1, you get something like this: Building…
A: Here I have created a class named Food. In this class, I have created constructors to set the value…
Q: An Electronics Shop wants to keep track of its inventory. It needs to save information about each…
A:
Q: Write a class encapsulating the concept of a team (for example, "Orioles"), assuming a team has only…
A: PROGRAM EXPLANATION: Create a class Team. Define the constructor for this class. Declare an…
Q: Write some Java code involving if, else if, and else statements that are equivalent to the following…
A: As per guidelines we are supposed to answer only one question. Kindly repost other questions as a…
Q: Dog objects have a few attributes, but this time unlike chair objects they can also do some cool…
A: Here I written C++ code as per your given problem below. I hop you like it. class Dog{} class…
Q: (A) Write a class called Course having data members: courseNum (String such as ITCS214), courseName…
A:
Q: Your task is to implement the Name class. This class represents a person's name. It has three…
A: The implementation of the name class is below: public class Name { // name class // variables…
Q: Drag and drop from the options below to declare an object of type "People", which takes a string as…
A: Declare an object of type "People", which takes a string as the first parameter for its constructor…
Q: Write a Java class called HotelRoom that represents a hotel room. The class will contain the…
A: Java Code for above : class HotelRoom{ int RoomNo; String PhoneNumber; int Capacity;…
Q: Implement the class Savings Account according to the following UML: Savings Account -annual…
A: The UML Class diagram is a graphical representation of classes, their attributes, methods,…
Q: Define and implement a class named animal that has the following constructor and attributes:…
A: Solution: Given, Define and implement a class named animal that has the following constructor…
Q: Write a class named NameAndCount for recording a String data name and an int data named count. A…
A: The NameAndCount class implements a Comparable interface. An interface is a class that contains the…
Q: For the Employee class, create the following: A private String instance variable m name. A private…
A: Screenshots of the code: 1.
Q: For the studentWorker class, create the following: A private int instance variable m hours. A…
A: A class is a group of objects having common properties. A constructor is a method that is used to…
Q: The Java feature in Q1 which create a new version of predefined method getPerimeter() is called…
A: ANSWER:- Polymorphism
Q: COMPLETE THE JAVA CODE BELOW SEE ATTACHED PHOTO FOR THE PROBLEM AND THE OUTPUT
A: In Employee class 1. added to String method 2. added earning method calculate earning by…
Q: In this exercise, you are given a Food superclass and two subclasses, Fruit and Meat. These methods…
A: Program Food.java: public class Food { private String name; privateint calories; public Food(String…
Q: can you please answer number 4 for me 1. Create a class called Student, with the following…
A: Class declaration is given below: public class Student{private String studentName;private int…
Q: Implementing the speak() method in each class. Take the Dog class for example: public void speak()…
A: Java Interfaces: Interface is similar to class but the methods declared in interface are by…
Q: ava Help Please! The Triangle series is a mathematical sequence of integers defined by the formula:…
A: Given: Java Help Please! The Triangle series is a mathematical sequence of integers defined by the…
Q: Extend the design of the class in Question 2 (a) to include a subclass, called MutatedHero, that…
A: we need to design a subclass which can be added to class,below i have written the required subclass…
Q: Write a testing class to create a Cat object. Invoke the speak method by each object and check the…
A: //interface definitionpublic interface Speakable{ //method declaration public void speak();}
Q: In this java assignment, we will be creating a pay stub for an employee using classes. Each class…
A: The above program makes use of Scanner class defined within java.util package that is used to take…
Q: 1. Create a class called Student, with the following attributes/variables: a. studentName (String)…
A: Answer: Our instruction is answer the first three part from the first part and . I have done code in…
Q: Your task is to implement the Name class. This class represents a person's name. It has three…
A: Actually, program is an executable software that runs on a computer.
Q: Write a class named IceCreamcup that implements the Customizable interface. The class should have…
A: Write class named IceCreamCup that implements Customizable interface having the following private…
Q: Create a class called Student, with the following attributes/variables: a. studentName (String) b.…
A: The solution to the given problem is below. ***Note: According to Bartleby policy we are not…
Q: ight triangle class with instance variables(double) for sideA, sideB and the hypo. write three…
A: We need to define the class RightTriangle per the given description.
Q: Given this class, please add the requested methods in the designated spaces provided. Instance…
A: public class Student { // declare instance variables here private int ID; private String…
Q: When you add a contact to your phone, it automatically sorts those names alphabetically. In this…
A: Given data addNumber- This method takes a PhoneNumber and adds it to the directory. Once the…
Q: In python, create a class horse that inherits the following attributes and methods from its parent…
A: #Parent class class Animal: #constructor def __init__(self,common_name, given_name, weight):…
Q: In this question, we will bake a class. Create a class Cake , with the following instance…
A: import random class Cake: name = "" ingreds = [] price = 0 #Constructor def…
Q: Assume a Student class contains a declaration for a method called getId () that returns a String.…
A: Method overriding means child class have same method name with same parameters with same return type…
Q: Write a shoe class with the following attributes: color (e.g., "blue", "green", "orange")…
A: Step 1:- Given:- 1.Create a class Clothing and its attributes are color,displayName, and price…
Q: Your task is to implement the Name class. This class represents a person's name. It has three…
A: Solution: create a class named Name Class Declare the variables firstname, lastname, middlename…
Q: Write a java program with the class name Vehicle. The class has three instance variables with names…
A: Basically, three classes are implemented. The Vehicle class is the base class and the Bus class is…
Q: Below is the class Greeter and its method, greet: public class Greeter { } public String greet() { }…
A: The program is written in Java. Check the program screenshot for the correct indentation. Please…
Q: Now we are going to use the design pattern for collecting objects. We are going to create two…
A: import java.util.ArrayList;class AmazonOrder{ final int length=5; ArrayList<Item> items;…
Q: For this exercise, you need to implement two (2) classes, the Rectangle class and the RectangleTest…
A: Since here no programming language is specified so we are providing the solution in Java. The…
Q: Your task is to implement the Name class. This class represents a person's name. It has three…
A: Actually, program is an executable software that runs on a computer.
Q: Write a complete Java class that can be used to create a Fish object as described below: A Fish…
A: public class Fish{ //Data members private String name; private int age; private String…
Q: Consider a class Movie that contains the following information about a movie: * Title * MPAA Rating…
A: Solution: Given,
Q: Consider a class Movie that contains the following information about a movie. The class has the…
A: The program is written in C++
Q: Your task is to implement the Name class. This class represents a person's name. It has three…
A: Actually, java is a object oriented programming language.
Q: You are given an interface AdvancedArithmetic which contains a method int divisor_sum(int n). You…
A: Java code: import java.util.*; //interfaceinterface AdvancedArithmetic { //abstract method int…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
- Hi, can i please get assistance with the following Java class below, where there is "TO DO:" I would like the task to be done please. Add anything relevant if needed only. The author class and the book class description is given. public class Book {private String title;private double averageRating;private String ISBN;private int numPages;// TO DO: insert an appropriate collection for associating Authors and initialise within constructors public Book(){} public Book(String title, double averageRating, String isbn, int numPages){ this.title = title;this.averageRating = averageRating;this.ISBN = isbn;this.numPages = numPages;}//accessorspublic String getTitle(){return title;}public double getAverageRating(){return averageRating;}public String getISBN(){return ISBN;}public int getNumPages(){return numPages;}// TO DO: provide an accessor for the collection on line 9 public String getAuthorList(){String authorList ="";// TO DO: insert code to return all author names separated by commas if…can you please answer number 4 for me 1. Create a class called Student, with the following attributes/variables:a. studentName (String)b. studentNumber (int)sc. regYear(long)d. faculty(String)e. department(String)2. Add the following methods in Student:a. accessors and mutators for all variablesb. toString methodi. Formulate your toString so that it only shows studentName,studentNumber and faculty3. Create a class called MyFriends, with the following attributes variables:a. studentArray(Student[])4. Add the following methods in MyFriends:a. fillArrayi. Using scanner ask how many students does the user want to inputii. Capture user input for all of his friends(Of course we are assuming all your friends would be similarUWC students, go ask around and meet new friends, alsopreferably not in the same Computer Science department … ifpossible … only if possible)b. maini. Call the fillArray methodii. Count how many Computer Science studentsiii. If half or more students are Computer Science…Implement a class Season that represents a season during a specified year. For purposes of thisproblem, assume that the seasons in each year are, in order, 'Winter', 'Spring', 'Summer', 'Autumn' .__init__, __repr__A Season object is created by calling the constructor and supplying two optional arguments:1. season, defaults to 'Winter'2. calendar year, an int , defaults to 2023For the __repr__ , see the usage below: The next and prev methods modify a Season object by changing it to the next season or previousseason in sequence, respectively. Note that the seasons can "roll over" or "roll back" and that this maychange the year by +/-1. 1. During each year, the seasons occur in this sequence: 'Winter', 'Spring', 'Summer', 'Autumn' 2. next - change to next season, if the current season is Autumn then year will increase by 1 3. prev - change to previous season, if Winter then year will decrease by 1 Implement the == operator ( __eq__ method) to compare two Season…
- (Java) Question 6 Explain the answer step-by-step and include verbal explanation. Thank you! Given the below Tesla class, update the class to inherit from the Comparable interface and also write a compareTo method that orders two Tesla objects according to 1. model, 2. range, and 3. color: public class Tesla { private String model; private int range; private String color; public Tesla(String model, int range, String color) { this.model = model; this.range = range; this.color = color; } @Override public boolean equals(Object o) { if (this == o) return true; } else if (!(o instanceof Tesla)) { return false; } else { Tesla t = (Tesla) o; return model.equals(t.model) && range == t.range && color.equals(t.color); } }}this is the whole problem i did 1 to 3 im stuck at 4 Create a class called Student, with the following attributes/variables:a. studentName (String)b. studentNumber (int)sc. regYear(long)d. faculty(String)e. department(String)2. Add the following methods in Student:a. accessors and mutators for all variablesb. toString methodi. Formulate your toString so that it only shows studentName,studentNumber and faculty3. Create a class called MyFriends, with the following attributes variables:a. studentArray(Student[])4. Add the following methods in MyFriends:a. fillArrayi. Using scanner ask how many students does the user want to inputii. Capture user input for all of his friends(Of course we are assuming all your friends would be similarUWC students, go ask around and meet new friends, alsopreferably not in the same Computer Science department … ifpossible … only if possible)b. maini. Call the fillArray methodii. Count how many Computer Science studentsiii. If half or more students are…When you add a contact to your phone, it automatically sorts those names alphabetically. In this exercise, we are going to create a phonebook that automatically sorts everytime a new number is added to the phonebook. A PhoneNumber class has been created already that has the instance variables name and number. Your job is to create the PhoneBook class that will store an ArrayList of PhoneNumbers. The PhoneBook class does not have a constructor - it only contains an ArrayList that can store the individual phone numbers that are added to it. There should be three methods in the PhoneBook class: addNumber- This method takes a PhoneNumber and adds it to the directory. Once the number has been added, the sort method is called on the directory to sort that new address into the phone book. sort- This method sorts the directory in alphabetical order A-Z.a. Remember that in order to compare Strings, we can use the compareTo() method. This returns an integer that indicates whether a String’s…
- box1 and box2 are instances of the Box class. Attributes length, width, and height of both box1 and box2 are read from input. Then, two strings are read from input. In the Box class, define instance method print_measurements() with self and one string as parameters to output the string parameter in one line, and the following in the next line: The value of attribute length ' by ' The value of attribute width ' by ' The value of attribute heightIn Java, please. Complete the Course class by implementing the findStudentHighestGpa() method, which returns the Student object with the highest GPA in the course. Assume that no two students have the same highest GPA. Given classes: Class LabProgram contains the main method for testing the program. Class Course represents a course, which contains an ArrayList of Student objects as a course roster. (Type your code in here.) Class Student represents a classroom student, which has three fields: first name, last name, and GPA. (Hint: getGPA() returns a student's GPA.) Note: For testing purposes, different student values will be used. Ex. For the following students: Henry Nguyen 3.5 Brenda Stern 2.0 Lynda Robison 3.2 Sonya King 3.9 the output is: Top student: Sonya King (GPA: 3.9) LabProgram.java import java.util.Scanner; public class LabProgram { public static void main(String args[]) { Scanner scnr = new Scanner(System.in); Course course = new Course(); int…In this java assignment, we will be creating a paystub for an employee using classes, files, getters, and setters. Each file should only have one class and the class should share the same name as the file. We are going to implement the following classes: Employee - This class represent the employee. It needs the following fields exposed via getters and setters: Employee ID (hard code it to 1) First name, last name, middle initial Address, city, zip Phone, email Hourly rate PayPeriod - This class represents an employee's payment information. An employee will eventually have more than one pay period. It needs the following fields exposed via getters and setters: Pay period Id (hard code to 123456) Employee Id Start date, end date Number of hours PayrollManager - This class provides the functionality we need to compute and display the payroll. It should implement the following methods: double CalculateGrossPay (Employee, PayPeriod) - this should return the total gross for the…
- Java Help Please! The Triangle series is a mathematical sequence of integers defined by the formula: triangle_number = Example: if we start with the integer 1, the series is: 1, 3, 6, 10, 15, 21, 28, 36, … Write a TriangleSeries class that implements Iterable. The TriangleSeries must have a constructor that allows us to specify the “start” number in the (sub) series we want to calculate, and the last number in the (sub)series. Also create a TriangleSequenceIterator that returns the proper integer in the series. Assume the starting value for the series is whatever start-value the client specified when they instantiated the TriangleSeries instance. Your iterator should return false for hasNext() when the “end value” is reached. For your convenience, here is the Iterator interface: interface Iterator<E> { boolean hasNext(); E next();}------ import java.util.Iterator;/** * Triangle Series Rule: t = n * (n + 1) / 2 */public class TriangleSeries implements Iterable<Integer>…This question concerns writing a Student class to model a student's name, composed of a first name, middle name and last name. The Student class should meet the following specification:Class StudentA Student object represents a student. A student has a first name, middle name and last name.Methodspublic void setNames(String first, String middle, String last)// Set the first, middle and last names of this Student object.public String getFullName()// Obtain the full name of this Student with the middle name converted to an initial only.2Thinking of the problem in terms of testing, there are three requirements that must be met:1. The setNames() method sets the names stored in the object i.e. the values of firstName, middleName, lastName.2. The getFullName() method obtains the name of the student with the middle name converted to an initial only.3. The getFullName() method does not change anything – i.e. it does not modify the values of firstName, middleName, lastNameHINT: To start your…1. Create a class called Student, with the following attributes/variables:a. studentName (String)b. studentNumber (int)sc. regYear(long)d. faculty(String)e. department(String)2. Add the following methods in Student:a. accessors and mutators for all variablesb. toString methodi. Formulate your toString so that it only shows studentName,studentNumber and faculty3. Create a class called MyFriends, with the following attributes variables:a. studentArray(Student[])4. Add the following methods in MyFriends:a. fillArrayi. Using scanner ask how many students does the user want to inputii. Capture user input for all of his friends(Of course we are assuming all your friends would be similarUWC students, go ask around and meet new friends, alsopreferably not in the same Computer Science department … ifpossible … only if possible)b. maini. Call the fillArray methodii. Count how many Computer Science studentsiii. If half or more students are Computer Science students, thendisplay “You … need more…