you will create a class called EmployeeFactory. This class will implement à simple version of the Factory Pattern. This class will contain a single static method: getEmployee (name : String, yearsofExperience : int) The method will return either an object of SeniorEmployee or an object of Junior Employee. If the employee's years of experience is greater or equals than five years, return a SeniorEmployee If the employee's years of experience is less than five, return a JuniorEmployee • If the years of experience is negative return null
Q: In this question, we will bake a class. Create a class Cake, with the following instance attributes:…
A: Answer:
Q: Your Community Supported Agriculture (CSA) farm delivers a box of fresh fruitsand vegetables to your…
A: Code: #include <iostream>#include <string>#include <cstdlib>#include…
Q: Suppose you have a class named Candy imported and you instantiate an object named reeses. Also,…
A: package Candy; public class Candy { String flavor= "sweet"; public String getFlavor() { return…
Q: Modify this class by: 1. Suppose the bank wants to keep track of how many accounts exist. A. Do…
A: Modified code: class Account{ private double balance; private String name; private long…
Q: You must write tests for the following: BankAccount Class Constructing a Bank…
A: BankAccount.java public class BankAccount { private String accountID; private double balance;…
Q: In this lab you will write three classes: Die, PairOfDice, and Player. The Die class mimics the…
A: Below are the classes required by given problem:
Q: Instructions Today you will be given a Frult class. From this, you will subclass Frult to make an…
A: /******************************************************************************…
Q: Following the example of the Rectangle class of Chapter 9 Exercise 1, design a class named Cuboid to…
A: PROGRAM INTRODUCTION: Define the class with the name cuboid. Declare the required constructor that…
Q: The goal of this problem is to repackage most of the previous code as a class that extends JFrame.…
A: /* Java GUI program to print a message on console when a button is clicked*/ /* Program without…
Q: Hello, I have to Design a class name Rectangle to represent a rectangle. The class contains: Two…
A: We need to write a program for given scenarios with uml diagram. The code has been written in…
Q: Write a method toString() for the Cow class which displays information about a Cow object. The…
A: Since no programming language is mentioned, I am using python. Assuming stomach is class variable of…
Q: Write a program that accepts two numbers. Use Scanner class to get the user input. Create 4 classes,…
A: Here I have created 3 different classes named Add, Subtract, and Multiply. In all the three classes…
Q: The goal of this problem is to repackage most of the previous code as a class that extends JFrame.…
A: /* Java GUI program to print a message on console when a button is clicked*/ /* Program without…
Q: I would like you to create a program that keeps track of the inventory (by make - e.g., Toyota) of…
A: In cases where there are multiple parts, we must answer first 3. Parts 1,2 and 3 have been…
Q: Modify a class named Circle with fields named radius, diameter, and area. Include a constructor that…
A: the code is an given below : Circle.java class Circle{double radius,diameter,area;…
Q: in java, Write a class that represents a student. Every student has a name, an id number, a number…
A: Program: import java.util.*; class student { // Declare variables String name; int id; double…
Q: Your task is to create a Circle constructor that creates a circle with a radius provided by an…
A: Algorithm - Design a method with one argument as a string. Now use the below logic to solve the…
Q: Create a class named Lease with fields that hold an apartment tenant's name, apartment number,…
A: Here, I have to write a java solution to the above question.
Q: java.util.Date birthDate and the following public instance methods: toString: Returns the animal’s…
A: First there is no set method since once DateOfBirth is defined, it shouldn't be manipulated. because…
Q: In this assignment, you will need to design and implement a class Country (Country.java) that stores…
A: Actually, program is a executable software that runs on a computer.
Q: Create a class named after your last name (e.g., Hasanov) with the following methods and…
A: public class Hasanov{ public static void main(String[] args) { //call methodShuffle…
Q: write a class called OneItemBag ( OneItemBag.java ). This class represents a bag that can hold any…
A: According to the question, we have to write code for a class called OneItemBag ( OneItemBag.java ).…
Q: Your task is to implement the following DigitalWallet class. The description of the class is as…
A: 1.DigitalWallet (double blnc, String ownr) 2.boolean pay(double amount) 3.boolean topUp (double…
Q: res plays the three variables' values in sentences. tor method with three parameters for the three…
A: I give the code along with output and code screenshot
Q: Write a class named PingPong that has a method next that alternates between printing 'PING' and…
A: Here is the python code: See below step for code.
Q: In Java Write a CashRegister class that can be used with the RetailItem class that you wrote in…
A: The complete code is given below.
Q: Following the example of the Rectangle class of Chapter 9 Exercise 1, design a class named Cuboid to…
A:
Q: P2. In this question, you are provided with a Date class and an incomplete EnhancedDate class. The…
A: import java.io.*; public class Date implements Serializable { // instance variables protected int…
Q: Modify the class named FormLetterWriter that includes two overloaded methods named…
A: Code in Java : public class FormLetterWriter { public static void main(String[] args) {…
Q: Create a class named Lease with fields that hold an apartment tenant's name, apartment number,…
A: The program is given below for the above given question:
Q: Modify the class named FormLetterWriter that includes two overloaded methods named…
A: Step-1: Start Step-2: Call function displaySalutation with argument "Kelly" Step-3: Call function…
Q: Draw the UML diagram for the class and then implement the class. Write a test program that creates…
A:
Q: Write a class named VowelCount.cs that is used to count the number of vowels in a given sentence.…
A: Write a class named VowelCount.cs that is used to count the number of vowels in a given sentence.…
Q: In this lab you will write three classes: Die, PairOfDice, and Player. The Die class mimics the…
A: import java.util.Random;public class Die { private int sides; private int face; public…
Q: Suppose there is a class called Thing and a method you attempt to call a method called myThing()…
A: there is a class called Thing and a method you attempt to call a method called myThing() like this:…
Q: Create a class called RoomCarpet that has three private instance variables – room length and width…
A: Create a Java class that has the private double data of length, width, and price. Create the gets…
Q: (The Rectangle class) Following the example of the Circle class in Section 9.2, design a class named…
A: Here we have to create a class in java named rectangle with the given properties. Algorithm Create…
Q: Write a class CountObject which has a method name numberfoObjects() which returns the number of…
A: Static is a keyword that is used for either variables or methods. Once it is declared as static…
Q: Write a class named PingPong that has a method next that alternates petween printing 'PING' and…
A:
Q: In this lab you will write three classes: Die, PairOfDice, and Player. The Die dass mimics the…
A: Q: Code the given problem in java
Q: Your task is to implement the following DigitalWallet class. The description of the class is as…
A: In this question we have to write a JAVA program, Where DigitalWallet class has to be executed with…
Q: Write a class called Name that has one instance variable to store the full name of a person. A name…
A: Program Explanation: Define a class for name Declare and define instance variables and constructors…
Q: You are required to build a class to represent the a cup of coffee. Call your class CoffeeCup. A…
A: Algorithm: Start Create a class CoffeeCup with type,temp,volume and sugar as its attributes…
Q: Question 1 Create a package named Lab6Q. Follow the parts outlined below: Part A: Add a public class…
A: Create a package name Lab6Q Define the below classes in this package : MyMethod RecComplexNum…
Q: Modify the class named FormLetterWriter that includes two overloaded methods named…
A: Please find the completed code below.
Q: Write a method toString() for the Cow class which displays information about a Cow object. The…
A: We have provided java code for given scenarios: We need to provide toString() method for given class…
Q: Write a class named WeightCheck which contains the following: 1. Instance variables: name (String)…
A: public class WeightCheck { private String name; private char sex; private double height; private…
Q: Create a class called Triangle that has two private instance variables: base and height (double).…
A: The variables declared here are private. Private variables can only be accessed by the class in…
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Java. create a class called employeefactory
Step by step
Solved in 2 steps
- hello This is in java Create a class called RoomCarpet that has three private instance variables – room lengthand width in foot (double) and carpet cost per square foot (double). Additionally, the classshould have:a. A constructor that takes room length, room width and carpet cost per square foot. Theconstructor sets the class variables to these values and in case any of these values isnegative, set its instance variable to zero.b. A mutator method (set) and an accessor method (get) for the carpet cost variable only.c. A method getArea that returns the area of the room. The area of the room iscomputed by multiplying the room's length by the room's width.d. A method getTotalCost that returns the total cost of the carpet. The total cost iscomputed by multiplying the room area by the carpet cost per square foot. Part (2)Write a Java application that asks the user to enter the length and width of a room and thecost per square foot of the carpeting. Create an object from RoomCarpet…I need to write a jave program to keep track of a team sport. Write a class, Team.java, that has the following: * two private instance variables: a String named color and an int named score. * a default constructor with no parameters that initializes color to "Red" and score to zero. * a constructor that takes two parameters (one for each instance variable) and sets the values of the instance variables. * a public getter and setter method for each instance variable. * a toString method that returns the color and score in the following format: "Red Team with 0 points."Modify the program below and add a public method called isZero() to the Fraction class. This method will determine if a Fraction represents a zero fraction. A zero fraction has a numerator == 0, no matter what the denominator is. Your isZero() method should return a Boolean resultindicating a zero fraction or otherwise. The method will be used by the client class to test whether the ‘calling fraction’ is equal to the number zero. Modify the program so that it now loops until a fraction representing zero is entered. //Import the essential package import java.util.ArrayList; import java.util.Scanner; //Define the class Fraction class Fraction { private int n, d; public Fraction() { //Initialize the values this.n = this.d = 0; } public Fraction(int n, int d) { //Initialize the variables this.n = n; this.d = d; } //Define the getter function getNum() that returns the numerator public int getNum() {…
- Suppose you have a class named Candy imported and you instantiate an object named reeses. Also, suppose that the Candy class has a method named getFlavor, which requires no arguments. Type the line of code that would run the method getFlavor on the reeses object.In Public Class, create a static void method called Info_AHW that takes 3 parameters - an int and two double. When the method is called, we pass along the age (A), then the height (H), and then the weight (W), which is used inside the method to print the person's age, then the height and then the weight. NOTE: The Print out must follow the output below Afterward, in the main method, get the User input using the Scanner class to get the three input - the int age, the double height and the double weight. Then, call your Info_AHW method and pass your arguments (age, height, weight) into that method. Hint: When getting the int input, use -> sc.nextInt(); When getting the double input, use -> nextDouble(); Input: 5 65.5 70.2 Output: Your age is 5 ; your height is 65.5 ; and your weight is 70.2 Note: -There is a single space between every word and semicolon -There is no space at the endIn this exercise, you have to implement a calculator which can perform addition, subtraction, multiplication, and division. Problem Statement# Write a Java class called Calculator with ● private fields: ○ num1 and num2 (double type) And methods: ● add(), a method which returns the addition of two numbers ● subtract(), a method which returns the subtraction of num1 from num2 ● multiply(), a method which returns the multiplication of numbers ● divide(), a method which returns the division of num2 by num1 ● Define a parameterized constructor which takes two parameters num1 and num2 and assigns these variables to the respective fields in the class. Input# Pass double point numbers in the parameterized constructor Output# addition, subtraction, division, and multiplication Sample Input# Calculator obj = new Calculator(10, 94); obj.add() obj.subtract() obj.multiply() obj.divide() Sample Output# 104 84 940 9.4 Part of the Solution class Calculator { // write class fields here public…
- I would like you to create a program that keeps track of the inventory (by make - e.g., Toyota) of cars on a used car lot. you will have to create two classes. The first is a simple Car class that consists of an inventory, make, and model. The second class you need to create for this challenge is the Lot. A Lot can contain many cars. Part 1 Write the Car constructor, get methods, and toString method. Part 2 Write the Car's increase and decrease inventory methods. Part 3 Edit the Car so it implements Comparable and compares Car instances based on their inventory in descending order. Part 4 Write the getCars and getCarsSorted methods of the Lot class. Part 5 Write the getInventory method of the Lot class. Part 6 Use a try/catch block in the Car's constructor so that it sets the inventory to 0 if the inventory passed to the constructor is not a valid integer. this is the output that should be produced by main: Make: [Toyota Camry (10), Toyota Prius (4), Toyota Rav4 (16)] [Hyundai…Create a class with name savingaccont.In this class you have to write the static method having name CalculteFutureValue which takes three parameters of type double along with return type double.This function should implement the formula given below.The formula, which is known as the future value formula, is:F = P * (1 + i)tThe terms in the formula are as follows: F is the future value of the account after the specified time period. P is the present value of the account. i is the monthly interest rate . t is the number of months . Write Driver class which contains main function that prompts the user to enter the account’s present value, monthly interest rate, and the number of months that the money will be left in the account. The program should pass these values to a function named CalculteFutureValue that returns the future value of the account, after the specified number of months. The program should display the account’s future value.In this lab you will write three classes: Die, PairOfDice, and Player.The Die class mimics the rolling of a die. Specifically, this class will implement the following methods:• A default constructor initializing the number of sides of a die to 6.• An overloaded constructor that takes an integer number of sides (assume greater than 1).• roll which generates and returns a random number between 1 and the number of sides(inclusive).• An accessor method to read the value of the face on the die.• A toString method returning the string representation of the face value.The maximum number of sides should be stored as a private constant in the Die class. Also use theRandom class for the random number generator.The PairOfDice class mimics the rolling of two dice. Specifically, this class will implement thefollowing methods:• A default constructor that creates and initializes the number of sides of each die to 6.• An overloaded constructor that creates and takes two integer number of sides, one…
- in java, Write a class that represents a student. Every student has a name, an id number, a number of credits, and a number of grade points. Also, include in your class a default constructor, a second constructor with all parameters, an accessor method (getter) for the student name, and a method called gpa that will calculate and return the student’s grade point average. (Hint: gpa = points/credits) Using the class that you just wrote, answer the following questions. Write code that will declare and initialize an object using the default constructor. Write code that will declare and initialize an object using the overloaded constructor. Write code that will retrieve and print the student’s gpa from #2.Please in pyth coding with correct indentation 4a) Given that you have a Liquid class that can be initialized with any amount of gallons, liters, ounces, etc, write the first line of the method that will allow you to add together two Liquid objects using operator overloading. Again, write ONLY the first line (method definition) – you do NOT have to write the entire method. 4b) Given that you have L1 and L2 which are instances of the Liquid class, write a line of code that uses operator overloading to add them together and assign the result to L3.Write a public int method named initialNumberOfSticks which takes two int parameters named max_sticks and min_sticks and returns a random integer value between max_sticks and min_sticks (inclusive). You will create a new instance of the Random class and call it r. Use the nextInt method of r to a get random value within a desired range and use it to compute the value that will be returned. Your method must be a syntactically correct Java method.