Concept explainers
Repeat Exercise 1 for a coin instead of a credit card.
Design a class to represent a credit card. Think about the attributes of a credit card; that is, what data is on the card? What behaviors might be reasonable for a credit card? Use the answers to these questions to write a UML class diagram for a credit card class. Then give three examples or instances of this class.
Trending nowThis is a popular solution!
Learn your wayIncludes step-by-step video
Chapter 5 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Software Engineering (10th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- Create your own UML diagram — similar to the above UML diagram — for a Pet class that meets thespecification below.1. Create the fields indicated below. Use these names exactly as given for your fields. Define them inexactly this order.• name — The name of the pet, e.g., “Rufus”, “Mittens”, “Smelly”, etc.• animal — The type of pet, e.g., “dog”, “cat”, “asparagus”, etc.• age — The (integer) number of years the pet has been alive, e.g., 1, 2, 3, etc.2. Create a mutator for each of the above in the order listed. Use the standard Java naming conventionfor mutators.3. Create an accessor for each of the above in the order listed. Use the standard Java naming conventionfor accessors.Example: Suppose you are taking the question for the example Car UML above instead of your Pet UML.Don’t enter any spaces at all.When the question asks: Enter line 1:You would enter: CarWhen the question asks: Enter line 2:You would enter: -make:StringWhen the question asks: Enter line 3:You would enter:…arrow_forwardDraw the UML diagram for the classes and implement them. Write a test program that creates a Person, Student, Employee, Faculty, and Staff, and invokes their toString() methods.arrow_forwardI have 5 classes in the picture, I want an uml drawing that expresses them ... I want it necessary, pleasearrow_forward
- This is the question: Design 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 similar to Figure 5.5 on page 180 of the textbook. 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.Hint: Remember that a horizontal line has a zero position in the middle with positive to the right and negative to theleft. Consider that a bug will land on the wire at some point before starting along the wire.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…arrow_forwardWhat is an interface and what is an abstract class? Please, expand by examples of using both. Explain why?arrow_forwardUse java programming properties to write all the necessary classes and/or interfaces for a solution to the problem. Focus on class structure and interaction. You may implement your solution however you wish, but you will be graded on the appropriateness of your solution to the requirements. Note the use of capitalization and parentheses for clarification. You may use whatever constructors or additional methods you wish. Define a structure that can represent Animals. Animals have two behaviors; they can speak() and they can move(). By default, when an animal moves, the text ”This animal moves forward” is displayed. By default, when an animal speaks, the text ”This animal speaks” is displayed. A general Animal should not be able to be instantiated. Define two classes, Goose and Lynx, that are Animals. Both Goose and Lynx behave such that where “Animals” is displayed in speak() or move(), “goose” or “lynx” is displayed by the appropriate classes. Finally, any instance of Goose can fly(),…arrow_forward
- Plese solve this with Java concept. Please write clearly. Thnak you in advance.arrow_forwardNow we are going to use the design pattern for collecting objects. We are going to create two classes, a class AmazonOrder that models Amazon orders and a class Item that models items in Amazon orders. An item has a name and a price, and the name is unique. The Item class has a constructor that takes name and price, in that order. The class also has getters and setters for the instance variables. This is the design pattern for managing properties of objects. The setName() method should do nothing if the parameter is the empty string, and the setPrice() method should do nothing if the parameter is not positive. The class also has a toString() method that returns a string representation for the item in the format “Item[Name:iPad,Price:399.99]”. For simplicity, we assume an Amazon order can have at most 5 items, and class AmazonOrder has two instance variables, an array of Item with a length of 5 and an integer numOfItems to keep track of the number of items in the…arrow_forwardDesign UML Class Diagram for the given scenario. Create a class Rectangle with attributes length and width, each of which defaults to 1. • Provide methods that calculate the rectangle's perimeter and area. • It has set and get methods for both length and width. • The set methods should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0.arrow_forward
- Below we have class diagrams with three classes for a simple java based parking management class. Use the classes below to write java code for classes :a parking observer class (that implements an observer pattern) , a transaction manager class and a parking lot class(subject to the observer). Use the class diagram and java class to implement it. You should use an observer pattern to implement your code.The main goal is to implement the following - Once a car enters (in an entry-scan only lot) or leaves (in an entry-scan and exit-scan lot), then the ParkingObserver will be updated, and then can register the charge with the parking system via the TransactionManager’s park() methodarrow_forwardI am having trouble determining how to tackle this question: Design and implement a class called Card that represents a standard playing card. Each card has a suit and face value. For your design, create a UML Class diagram similar to Figure 5.5 on page 180 of the textbook. Note that you need to include the two constructors in the methods section (i.e., they must be coded). Hints: Represent the faces/ranks of Ace through King as 1 through 13 and the suits as 1 through 4. You need two constructors: one that receives a face/rank value and suit value as parameters, plus the default constructor where these values are randomly generated. The face/rank and suit must both have appropriate get_ and set_ methods for the numeric values plus a get_ method for the textual equivalent (e.g., getFace() might return 13 while getFaceText() would return “King”). Your toString method should return a nice representation of the values like “Ace of Spades” or “Nine of Hearts.”Write a test driver…arrow_forwardDraw and explain the chart for implementing accessibility control using package in Java. Write program for the following. 1. Create an abstract parent class Parent, with Abstract method show, Abstract method display, Concrete method callme 2. Create two concert sub classes Child1 and Child2 which inherits the Parent class. 3. Declare a reference variable of the parent class and create one object for each child class. 4. Assign the reference of the object of child class to the reference variable of the parent class and implement dynamic method dispatch for all the possible methods in each child class.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