Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 1, Problem 21E
Create an object of class Student. You will notice that this time you are prompted not only for a name of the instance, but also for some other parameters. Fill them in before clicking OK. (Remember that parameters of type String must be written within double quotes.)
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Add 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,…
Must be written in Python. Please include docstring and show how output should look like. Remember that all data members should be private. An object can access it's own private data members directly. It can also access the private data members of other objects of the same class directly. But when accessing a private data member of an object of another class, it needs to call the appropriate get method. If that sounds complicated, just remember this: if a method is in the same class as a private data member, then it can access that data member directly, otherwise, it needs to use a get method.
Write a class named Point that has two data members, x_coord and y_coord, representing the two coordinates of the point. It should have:
an init method that takes two arguments, an x-coordinate and y-coordinate (in that order), and uses them to initialize the two data members.
get methods for the two data members: get_x_coord and get_y_coord.
a method named distance_to that takes a Point object…
In this assignment, you will need to add a new method to the Date class, which you
can find on D2L in the "Sample Code" section.
The new method should make a Date object's day, month, and year value change to
the next day. In other words, add one day to the object's current date. Do not use any
part of the built-in DateTime class, but you may want to use the DaysInMonth()
method from the Date class.
Examples:
• If the Date object stores the date 12/31/2021, then after calling your method
it should store the date 1/1/2022
• If the Date object stores the date 2/28/2022, then after calling your method it
should store the date 3/1/2022
As noted in the common instructions, you only need to turn in your new method, not
the entire Date class.
Chapter 1 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 1 - Prob. 1ECh. 1 - Prob. 2ECh. 1 - Prob. 3ECh. 1 - Prob. 4ECh. 1 - This is a very simple example, and not many colors...Ch. 1 - Prob. 6ECh. 1 - Prob. 7ECh. 1 - Prob. 8ECh. 1 - Prob. 9ECh. 1 - Select Show Terminal from the View menu. This...
Ch. 1 - Select Show Code Pad from the View menu. This...Ch. 1 - Prob. 12ECh. 1 - Prob. 13ECh. 1 - Prob. 14ECh. 1 - Look at the pop-up menu of class Picture again....Ch. 1 - In the source code of class Picture, find the part...Ch. 1 - Add a second sun to the picture. To do this, pay...Ch. 1 - Prob. 18ECh. 1 - Prob. 19ECh. 1 - Prob. 20ECh. 1 - Create an object of class Student. You will notice...Ch. 1 - Prob. 22ECh. 1 - Prob. 23ECh. 1 - Call the numberOfStudents method of that class....Ch. 1 - Look at the signature of the enrollStudent method....Ch. 1 - Prob. 26ECh. 1 - Prob. 27ECh. 1 - Prob. 28ECh. 1 - Prob. 29ECh. 1 - In this chapter we have mentioned the data types...Ch. 1 - What are the types of the following values?...Ch. 1 - Prob. 32ECh. 1 - Write the header for a method named send that has...Ch. 1 - Prob. 34ECh. 1 - Prob. 35ECh. 1 - Prob. 36E
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Explain the problems that denormalized tables may have for insert, update, and delete actions.
Database Concepts (8th Edition)
Identify the important constituents of the control mechanism in the routines of the previous problem. In partic...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
What three steps must be taken by a program when it uses a file?
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
A file that contains a Flash animation uses the __________ file extension. a. .class b. .swf c. .mp3 d. .flash
Web Development and Design Foundations with HTML5 (8th Edition)
A (n) _______operator determines if a specific relationship exists between two values.
Starting Out With Visual Basic (8th Edition)
T F The same output formatting techniques used with cout may also be used with file stream objects.
Starting Out with C++ from Control Structures to Objects (9th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- The first version of Abby’s Eggs worked but was a bit cumbersome. I.e. you couldn’t edit a single parameter, you had to always re-enter all of them. Store the parameters (number of chickens, eggs laid per day, etc.,) in static fields of the class. Have separate methods for updating the parameters. Use a switch statement to take menu selections for updating parameters or outputting results. If the menu choice is 0, the program should terminate, invalid inputs should be ignored and any prompt repeated. Before displaying updated menu, “clear the screen” I got most of the code working, but I can't find a way to clear the sceen before displaying the updated menu. I tried using "System.out.print("\033[H\033[2J"); System.out.flush();", but it is not working. I am using the Apache NetBeans IDE.arrow_forwardChallenge exercise The following object creation will result in the constructor of the Date class being called. Can you write the constructor’s header? new Date("March", 23, 1861) Try to give meaningful names to the parametersarrow_forwardFor this lab task, you will work with classes and objects. Create a class named text that works similar to the built-in string class. You will need to define a constructor that can be used to initialize objects of this new class with some literal text. Next, define three methods: to_upper() that will convert all characters to uppercase, reverse() that will reverse the text and length() that will return the length of the text. After you have completed this part, copy the following mainfunction to your code and check if the implementation is correct. int main() { text sample = "This is a sample text"; cout << sample.to_upper(); // This should display "THIS IS A SAMPLE TEXT" cout << endl;cout << sample.reverse(); // This should display "txet elpmas a si sihT"cout << endl; cout << sample.length(); // This should display 21 }arrow_forward
- Write a main method, in which you should have an Arralylist of students, in which you should include every student. You should have a PhD student named Joe Smith. In addition, you should create an Undergraduate student object for each of your team members (setting their names). If you’re only one person doing the assignment, then you should just create one undergraduate object. For each undergraduate student, you should add add two courses (COIS 2240 and COIS 1020). Loop over the arraylist of students, print their names, if the student is an undergraduate student, print their courses.arrow_forwardCreate another ticket machine for tickets of a different price; remember that you have to supply this value when you create the machine object. Buy a ticket from that machine. Does the printed ticket look any different from those printed by the first machine?arrow_forwardYou are going to be working with class Rational which defines rational number objects. A rational number is a number that can be written as a fraction. A rational number consists of a numerator and a denominator (which cannot be 0). Rational numbers also have the ability to be displayed in an original form, decimal form or reduced form. You are going to be completing various object methods to perform the tasks previously list. You are to begin with the Rational Class and RationalTest classes provided. Make all modifications outlined in the point values below. Pay close attention to the names of the attributes, methods and return values. You are given starter files and the test files necessary. Only modify class Rational and keep the function headers provided to you for all of Part 1. You will need to add your own methods for Part 2. Part 1a This version requires that you complete the constructor, getOriginal(), and getDecimal() methods of class Rational. Constructor: at this stage…arrow_forward
- Help with codearrow_forwardThese two pictures are my resource and driver classes. Please, help me with the error in my resource class. I want my resource class to have getName, getSalary, getThePercentageThatTheEmployeeWantToRaise, and calculateTheNewSalary methods. For my driver class, I want the driver class to ask the user to input their name, salary, how much they want to raise, and print out their new salary.arrow_forwardAdd a String instance variable, messageUponExiting, to the Window class. This variable will be used to display a message when the user closes the window (for example, "Are you sure you want to quit?"). Furthermore, this variable should be accessible to all subclasses of the Window class, as each sort of window may require a different message upon exiting. Please provide the declaration of the instance variable only—nothing else.arrow_forward
- Create an object of class LabClass. As the signature indicates, you need to specify the maximum number of students in that class (an integer).arrow_forwardTHIS DOESNT WORK WITH THE TEST CLASS PROVIDED, PLEASE ENSURE THAT IT DOES!arrow_forwardPlease answer the question in the attachment. It is a past AP Computer Science frq question that has already been answered, but I would like to see another way to approach the problem.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4;License: Standard YouTube License, CC-BY