To create a new project, heater-exercise with a new class Heater and declare a single variable temperature of type double. The value of the variable temperature is set to 15.0 using the constructor. Two methods, warmer() and cooler() are used to change the temperature by 5.0 degrees. An accessor method, getTemperature() is also used.
Program Plan:
Write a program in BlueJ to create a new class Heater. In the class, a single variable temperature of type double is used. The value for the field temperature is set to 15.0 using the constructor. The method warmer() increases the temperature by 5 degrees and cooler() decreases the temperature by 5 degrees. The method getTemperature() is used to return the value of the temperature.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- Part I Create a Ticket class. The design is up to you. Write the necessary methods. Part II Create a MovieTicket class that inherits from Ticket class. The design is up to you. Write the necessary methods. Part III Create a Theater class. The design is up to you. Write the necessary methods.arrow_forwardDesign and implement a class called Bug, which represents a bug moving along a horizontal wire. The bug can only move for one unit of distance at a time, in the direction it is facing. The bug can also turn to reverse direction. For your design, create a UML Class diagram . Note that you need to include the constructor in the methods section if you code a constructor. Bug will require a toString method to return the current position and which direction the bug is facing to the driver so it can be output Write an interactive test driver that instantiates a Bug, then allows the user to manipulate it with simple commands like Output (to see the position and direction), Move, Turn, Exit ... single letters work just fine. All output should be via the driver not methods within Bug. You should use this driver to create screenshot exhibits for a number of scenarios (e.g., output original position, move a few times, output, move a few more times, output, turn, output, move, output, etc.).…arrow_forwardCreate a code the follow way: Each student object should also contain thenumber of earned credits. Provide a constructor that sets this value based on parameter value. Overload theconstructor such that the number of earned credits is initially zero. Provide setter and getter for this newfield. Modify the toString method such that the new information is included in the description of thestudent. Modify the driver class main method to exercise the new Student methods.arrow_forward
- You are in charge of designing an enemy character of a video game using OOP. The video game is a side-scrolling arcade game, where the protagonist should evade numerous enemy characters. Assuming there are five different types of enemy characters and each is represented using a class, describe what methods and variables Mention at least three each. Also describe the purpose and motivation of each variable and method. Do not provide a code as an answer.arrow_forwardPlease write code in JAVA Step 1: An Account class stores a current balance, and provides getBalance, deposit, withdraw, and toString methods in addition to at least one constructor. Add an account class to the project.Step 2: A CheckingAccount class extends the Account class and has additional attribute overdraft limit and additional method chequeDeposit. Implement the CheckingAccount class in the project. Make sure you add a constructor to the class.Step 3: Override the toString method in the CheckingAccount class to add the overdraft limit as well to the returned string.Step 4: A SavingsAccount class extends the Account class and has additional attribute interest rate and a method named addInterest to calculate and add the interest to the account. Implement the SavingsAccount class in the project. Implement the SavingsAccount class in the project. Make sure you add a constructor to the class.Step 5: Add a test class named AccountTester to the project and implement a main method in…arrow_forwardCreate a Java Project (with a First class and a test class) to represent some real-world Objects such as an animal, a person, a vehicle, etc. The First class will: 1. Create a total of 3 member variables for the class, selecting the appropriate data types for each field. 2. Include at least 1 different constructor method, in addition to the default constructor (0 argument constructor). 3. Include getters/setters to serve as mutators and accessors for each variable. 4. Create at least two other member functions (methods) for the class that will perform some operation on the data (i.e. calculations or additional report/display of output). The Java test class (with a main method) will: 1. Instantiate at least two objects (using each of the constructors at least once) with your program [Note: Set the remaining data with the mutators (setter) methods. 2. Store the data from the individual objects into an array. 3. Include the below in your project report: 1) Code for all classes. 2)…arrow_forward
- can someone help me? The questions are: 1. Add an addExerciseAdd method that adds an exercise to a private variable exercises in Exercise You don't need to create a getter or setter for this private variable. 2. Modify the constructors in Exercise so that you can create two types of workouts (let one constructor use the other; each variable can only have a value in one constructor): a training schedule with exercises, but without a trainer. a training schedule with exercises and with a trainer. import java.util.ArrayList;class Exerciseplan {private String customer;private String trainer;Exerciseplan(String customer) {this.customer = customer;}Exerciseplan(String customer, String trainer) {this.customer = customer;this.trainer = trainer;}private void printExercise(String name, String muscleGroup, Integer numberOfSets, Integer repetition, Integer restTime) {System.out.println("Oefening voor " + muscleGroup + ":" +" herhaal " + numberOfSets + " keer " +"(rust tussendoor " + restTime +…arrow_forwardjava programmingarrow_forwardAssume that CSCourse class has been written, which has the below UML Diagram. You are giyen the CourseManager class and are asked to complete the main method. Write a body of the main method only that creates two objects of type CSCourse, so that: the first CSCourse is named "CS210% and has 32 students and an average GPA of 3.1 the second CSCourse is named "CS211" and has 31 students and an average GPA of 3.4 sum the students in two courses using the getNumStudents() method, and print the sum to the screen. C) cSCourse name : String -numStudents: int -averageGPA double +CSCourse(name String, numStu int) +getNumStudents() int +getName(): String +setAverageGPA(AVGPA: double) : void public class CourseManager{ public static void main(String[] args) [ / Your code goes here // Sample output is "Sum of students: 63".arrow_forward
- Need an example of this format in java programming in eclipse Create a class 1. Define instance data fields 2. Define a constant properly; use the constant when needed 3. Define a constructor that receives parameters for instance data 4. Generate get and set methods for instance data (even though some methods may not be used) 5. Define 4 other methods • method one will not receive any parameters, but will return a value to the driver program • method two will receive one parameter, and will also return a value to driver program • method three will receive one parameter, and will also return a value to driver program • method four will receive 3 parameters from driver program and will be responsible for displaying all output B. Create a driver program 1. Instantiate objects passing specific data to the programmer written constructor 2. Call each of 3 methods, for each instantiated object, passing any required arguments, and saving any values being returned in a variable 3. Call the 4th…arrow_forwardPlease help with the following question: Code in Java You need to deliver one project consisting of only one main class and three other classes stated below. For each of the classes you create you need to use the constructor to set its attributes. Your classes have to have setters and getters and their attributes should all be private. Create a class University A university has the following attributes. 1. A university name (string)2. A university population (int)3. A university budget(double) Create a class Department This class has this attributes: 1. Dep Name(string)2. Dep ID(int) Create a class Student A student has the following attributes. 1. An ID(int)2. A Name(string)3. A DEP ID(int) In the main class first Create three departments.Ask the user to input the field values. In the main class create 5 students. Ask the user to input the field values. Write a function in the main class that takes two integers as input and Checks if they are equal. Use that function to check if for a…arrow_forwardAdd comments as appropriate. Be sure that your program output is neatly presented to the user. Add documentation comments to your functions. You are going to change the class you created in Program7 so that it has a constructor and some properties. In your GeoPoint class make the following changes (note your variable, parameter and method names may be different. Adjust as needed.): Add a constructor __init__(self, lat=0, lon=0,description = ‘TBD’) that will initialize the class variables __lat ,__lon and the __description. Notice that the constructor will also default lat and lon to zero and description to ‘TBD’ if they are not provided. Change the SetPoint method so that instead of individual coordinates SetPoint(self, lat, lon) it takes a single sequence. Add a property: Point = property(GetPoint,SetPoint). Make sure GetPoint and SetPoint are the names you used for the get and set methods you already wrote for points. Add another property: Description = property(GetDescription,…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education