1. Class name is Area; 2. It has 2 fields namely n1 and n2, declared as integer. 3. The 2 fields must only be accessible within the class. 4. There is a constructor that is capable of accepting values for 1 field called x. 5. There is another constructor that is capable of accepting values for 2 fileds called x and y: 6. Create the code inside the constructors. The codes will simply assign value of x and y to n1 and n2, respectively. 7. Specify the appropriate access modifier for the constructors.
Q: Please Write a class named Student that has the following variables: name - a string that hold…
A: The program is implemented in C++ with object oriented approach. The question asks me to make 3…
Q: Create a class named Ship that has two private fields one for the name (string) of the ship, and the…
A: public class Ship { private String name; private String year; public Ship(String name, String year)…
Q: - a constructor that takes two values corresponding to the xcoord and ycoord values and sets them…
A: In the above question, the request is to create a C# class called Point that can store x and y…
Q: a. Modify the FitnessTracker class that includes data fields for a fitness activity, the number of…
A: The answer is givenbelow:-
Q: Write a class named Point that contains: . public int field named a. . public int field named b.…
A: Note: There is no main method so the output of the successful compilation is given in this solution.…
Q: Temp Class - Create Temp class whos job is to hold a temp in degrees F and gives methods to get the…
A: Actually, Java is a high level programming language. And also object oriented .It. Is a platform…
Q: Create a Puppy class with private property color and both a getter and a setter for that property…
A: The Puppy class with a private property color and provides both a getter (getColor) and a setter…
Q: When an object variable is declared, what happens if the programmer did not write a constructor for…
A: A Constructor is a special method in a class which has the same name as that of class
Q: Fruit class has two data fields called color and seed. 2. A private data field called season. 3.…
A: Here In this program, we are going to make three classes- 1- fruit{ String color,seed; Private…
Q: Design a class named MyDouble. The class contains: . An int data field named value that stores the…
A: The code along with code screenshot and sample output is provided. The value data field is made…
Q: For this program you need to create 3 classes: Ironman This class will be the base class The name…
A: As per the requirement program is developed. This concept is called multi level inheritance. Note:…
Q: e NOT true for a constructor? Select one: a. It does not return anything b. Every class must include…
A: Solution - In the given question , we have to select the incorrect statement for a constructor among…
Q: Create a class named FootballTeam. Include two fields that hold data about the teams participating…
A: Note: Three classes has been created for the given criteria. File name: "FootballTeam.java" public…
Q: Write a class named Aircraft that has the following member variables: xear - An variable that holds…
A: Aircraft.javapackage bartleby; public class Aircraft { int year; String make;…
Q: In Javascript, Pet Class: Design a class named Pet, which should have the following fields and…
A: I have provided JAVASCRIPT CODE along with CODE SCREENSHOT and OUTPUT…
Q: The Triangle class) Design a class named Triangle that extends GeomericObject. The class contains:…
A: Hi, Please find the answer below:------------------------------- Java Program: package triangle;…
Q: Attached you will find a Java class called Employee. This class includes a constructor which sets…
A: The class manager is a Java class which inherits class Employee. Since the data members of class…
Q: Part A Create a FitnessTracker class that includes three data fields for a fitness activity: a…
A: The question does not specify any particular programming language for the solution. We have done the…
Q: Create a class named Grades, which has four fields, one for the name of the student, and three other…
A: Below is the JAVA program: - Explanation: - Importing the package. Creating class Grades.…
Q: True or False Class fields are almost always declared public in order to make their values easily…
A: Correct answer of the following question is:
Q: ava. Check ‘n Shop is a grocery supermarket in South Africa that provides a loyalty program to…
A: The given problem is to be solved in Java where 2 classes are needed as below: 1. Shopper.java 2.…
Q: Create a class called Account. Having private fields custname and protected field balance Define a…
A: Step 1: Create class with member variable name and balance Step 2: Accept name and balance Step 3:…
Q: 1. The Rockford Daily Clarion wants you to design a class named Issue. Fields include the issue…
A: ANSWER:-
Q: Practice with writing a program that contains three classes: Ship CruiseShip CargoShip Classes…
A: Solution - Programming language used: Java All solution steps are included in program code as…
Q: Object-oriented programming Create a class called Triangle that models triangles using three points…
A: Triangle has three sides and there vertices. Let the vertices be (x1,y1) , (x2, y2) and (x3, y3)…
Q: in netbeans Write a complete class named Crab that includes a String property named myColor and an…
A: This is an oops question in which we have to make a class named Crab that includes a String property…
Q: Part A Create a FitnessTracker class that includes three data fields for a fitness activity: a…
A: 1. Class Definition (FitnessTracker): 1.1 Declare private data fields: activity (String), minutes…
Q: Design a Book class that holds the title, author’s name, and price of the book. Books’s constructor…
A: [Note: Since no language is mentioned, C++ is used. This code should be rewritten instead of…
Q: . Dummy GUI Application by Codechum Admin A GUI Application is an application that has a user…
A: First, implement another class called Checkbox which implements the Clickable interface which has…
Q: - The class has data members that can hold the name of your cube, length of one of the sides and the…
A: The answer to the following question:-
Q: Write a class named Car that has the following fields: The yearModel field is an int that holds the…
A: Main.java import javax.swing.JOptionPane; public class Car { private int Speed = 0; private…
Q: A. Food Class 1. The food class is defined by the three following properties: name of the item,…
A: import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner…
Q: Create a Puppy class with private property color and both a getter and a setter for that property…
A: Create a class called Puppy.Inside the Puppy class, define a constructor method __init__ that takes…
Q: Design a class named Computer that holds the make, model, and amount of memory of a computer.…
A: Answer in Step 2.
Q: In C#, a program that implements and uses a class called MyRectangle. Data items should include:…
A: We must define particular data types, attributes, and methods in accordance with the specifications…
Q: for this question do not write the code just explain how you would Create a class called Elevator…
A: Please find the detailed answer in the following steps.
Q: Construct a Time class containing integer data members seconds, minutes, and hours. Have the class…
A: #include <iostream>#include <iomanip>using namespace std;// class declaration…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- 5. class definition for GameEnemy Next, we want to start making enemies for our upcoming video game, so we will define a class called GameEnemy. Every GameEnemy will have a name, an x location, a y location, and a number of hit points (which must be a non- negative integer ). The_init__ method for GameEnemy will take all of these parameters (in that order) and store them on the object. GameEnemy also needs a method called healthbar, which will allow us to show that enemy's health bar in the game. It returns the enemy's name followed by a number of asterisks to show how many hit points it has left. The exact format is shown below. Sample runs should look like: >>> enemy = GameEnemy ("TODD", 100, 200, 5) >>> enemy.healthbar() TODD: ****** >>> enemy-% ence 100 >>> enemy-y 200 If vou havo qu octionaCar ClassWrite a class named Car that has the following fields:• yearModel. The yearModel field is an int that holds the car’s year model.• make. The make field references a String object that holds the make of the car.• speed. The speed field is an int that holds the car’s current speed. In addition, the class should have the following constructor and other methods.• Constructor. The constructor should accept the car’s year model and make as arguments. These values should be assigned to the object’s yearModel and make fields. The constructor should also assign 0 to the speed field.• Accessors. Appropriate accessor methods should get the values stored in an object’s yearModel, make, and speed fields.• accelerate. The accelerate method should add 5 to the speed field each time it is called.• brake. The brake method should subtract 5 from the speed field each time it is called.Demonstrate the class in a program that creates a Car object, and then calls the accelerate method five…Design a Ship class that the following members: A field for the name of the ship (a string). A field for the year that the ship was built (a string). A constructor and appropriate accessors and mutators. A toString method that displays the ship’s name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: A field for the maximum number of passengers (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The CruiseShip class’s toString method should display only the ship’s name and the maximum number of passengers. Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: A field for the cargo capacity in tonnage (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The…
- 1. Write a class named Coin. The Coin class should have the following field: • A String named sideUp. The sideUp field will hold either "heads" or "tails" indicating the side of the coin that is facing up. The Coin class should have the following methods: • A no-arg constructor that randomly determines the side of the coin that is facing up ("heads" or "tails") and initializes the sideUp field accordingly. • A void method named toss that simulates the tossing of the coin. When the toss method is called, it randomly determines the side of the coin that is facing up ("heads" or "tails") and sets the sideUp field accordingly. • A method named getSide Up that returns the value of the side Up field. Write a program that demonstrates the Coin class. The program should create an instance of the class and display the side that is initially facing up. Then, use a loop to toss the coin 20 times. Each time the coin is tossed, display the side that is facing up. The program should keep count of…Design a Book class that holds the title, author’s name, and price of the book. Books’s constructor should initialize all of these data members except the price which is set to 500/-. Create a display method that displays all fields. All Books are priced at 500/- unless they are PopularBooks. The PopularBooks subclass replaces the Bookprice and sets each Book’s price to 50,000/- through PopularBooks construcor. Override the display method to display all fields. Write a Main () method that declares an array of five Book objects. Ask the user to enter the title and author for each of the 5 Books. Consider the Book to be a PopularBook if the author is one of the following: Khaled Hosseini, Oscar Wilde, or Rembrandt. Display the five Books’ details. c sharp3- Create a class named Player with a default name as "player", a default level as 0, and a default class type of "fighter". Feel free to add any other attributes you wish! Create an instance method in the Player class called attack that takes another player as a parameter. This function should compare the level of the two players, and return whether the player won, lost, or tied. Finally create a loop that allows the user to input a name and a class type for two players; the level of both players should be determined at random (between 1 and 99). Print out the name and attributes of each player, and have the first player attack the second. Print whether the player won, lost, or tied. Ask if the user wants to try again. (Python code)
- 1- Design a class named Rectangle to represent a Rectangle. The class contains: • three variables integer data field named height, integer data filed named width and integer data filed named length. The default values are 1 for height, length, and width are 1.0 for each of them respectively. • A no-arg constructor that creates a default Rectangle. • A constructor that creates a Rectangle with the specified height, length and width. • A method named getVolume() that returns the volume of this Rectangle. (Volume = height * width * length) %3! 2- Write a test program called Test Rectangle that: • Creates two Rectangle objects: one object with height 11, length 5, and width 7, the other object with height 10, length 2 and width 6 • Display the volume of each Rectangle object.1. Create a class as described below: Class Name: Room Fields: standard room fee amenities total cost Constructors:A default constructor to initialize the fields. The standard room fee field should be set to $200 and the amenities field to zero. Another constructor with one argument. It should assign this value to the standard room fee and the amenities field to the default value of $75. Methods: getStandardFee() - This methods returns the standard room fee field value. getAmenities() - This method returns the amenities field value. getTotalCost() - This method returns the total cost field value. calcTotalCost() - This method calculated the total cost for an instance of the class setStandard Fee() - This method has one argument representing the standard room fee. setAmenities() - This method has one argument representing the amenities for the room.in C#, Visual Basic Create a Car class that has at least the following properties:• Year• Make• Price• Passengers-holds the number of seat belts available in the car (presumably how many passengers the car can hold). This field must be private since users presumably can’t change this value. Have two constructors: one that initializes everything to some default value for the base price of a car and one that also accepts values for luxury upgrades of: heated seats, sun-roof, and satellite radio. The class has two methods: 1) Get Paint Color() which accepts a standard base color option but allows the user to purchase a pricier customized color 2) Upgrade Costs() which computes the cost of user-selected luxury items and adds it to the price. Create three car objects: Ford (make Explorer), Lexus (make ES) and a Clown Car which overrides the passenger value to allow 20 clowns in the car. The Get Paint Color() and Upgrade Costs() functions needs to be called for each object and data for all…
- Design a Ship class that has the following members:• A field for the name of the ship (a string).• A field for the year that the ship was built (a string).• A constructor and appropriate accessors and mutators.• A toString method that displays the ship's name and the year it was built.Disign a CruiseShip class that extends the Ship class. The CruiseShip class should have thefollowing members:• A field for the maximum number of passengers (an int).• A constructor and appropriate accessors and mutators.• A toString method that overrides the toString method in the base class. The CruiseShipclass's toString method should display only the ship's name and the maximum number ofpassengers.Design a CargoShip class that extends the Ship class. The CargoShip class should have thefollowing members:• A field for the cargo capacity in tonnage (an int).• A constructor and appropriate accessors and mutators.• A toString method that overrides the toString method in the base class. The CargoShipclass's…Dice Rolling Class In this problem, you will need to create a program that simulates rolling dice. To start this project, you will first need to define the properties and behaviors of a single die that can be reused multiple times in your future code. This will be done by creating a Dice class. Create a Dice class that contains the following members: Two private integer variables to store the minimum and maximum roll possible. Two constructors that initialize the data members that store the min/max possible values of rolls. a constructor with default min/max values. a constructor that takes 2 input arguments corresponding to the min and max roll values Create a roll() function that returns a random number that is uniformly distributed between the minimum and maximum possible roll values. Create a small test program that asks the user to give a minValue and maxValue for a die, construct a single object of the Dice class with the constructor that initializes the min and max…Create an Account class that a bank might use to represent customers’ bank accounts. Include a data member to represent the account balance. Provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it is greater than or equal to 0. If not, set the balance to 0. Provide three member functions:- credit($amount) should add amount to the current balance- debit($amount) should ensure that amount does not exceed the current balance and then reduce the current balance by amount. The balance should not change if amount exceeds the balance.- getBalance() should return the current balanceNote: Create a set of test data and then write a program to test the class.