-
Design a Java interface called Priority that includes two methods: setPriority and getPriority. This interface would define a way to establish numeric priority among a set of objects. Your numeric priority values should be on a scale. For easy comparing of priorities, make 1 the lowest priority. It should be more complex than just 1, 2, 3 (low, medium, high). Define constants in the interface for the low, medium, and high priority values. Design and implement a class called Task that represents a task (e.g., something on a to-do list) that implements the Priority interface from above, as well as the Comparable interface from the Java standard class library. A task should have some sort of description. Illustrate your design with a UML class diagram. Create a driver whose main method exercises some Task objects. Make sure you have enough tasks to produce comparisons where a given task is higher, lower, or equal in priority to some other task. Implement the interface such that the tasks are ranked by priority. Create a driver class that shows these new features of Task objects.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images
- In java and UML diagram, Please show output and comment code out Source file: Each public class must be contained in a separate Java source file. Only one source file will have a main() method and this source will be named BlackjackGameSimulator.java. Other source/class names are up to you following the guidelines specified so far in the course. The format of the Java source must meet the general Java coding style guidelines discussed so far during the course. Pay special attention to naming guidelines, use of appropriate variable names and types, variable scope (public, private, protected, etc.), indentation, and comments. Classes and methods should be commented with JavaDoc-style comments (see below). Please use course office hours or contact the instructor directly if there are any coding style questions. JavaDocs: Sources should be commented using JavaDoc-style comments for classes and methods. Each class should have a short comment on what it represents and use the @author…arrow_forwardDesign a class called Post. This class models a StackOverflow post. It should have properties for title, description and the date/time it was created. We should be able to up-vote or down-vote a post. We should also be able to see the current vote value. In the main method, create a post, up-vote and down-vote it a few times and then display the the current vote value.arrow_forwardplease answer with outputarrow_forward
- Explore scenarios where you might need to implement a custom Comparator for a class that already implements the Comparable interface. Provide real-world examples for context.arrow_forwardJava provides one interface to sort objects of user defined types. What is the name of this interface type. Use an example to describe how to implement this interface.arrow_forwardWrite a Java program for a class called MyPoint, which models a 2D point with x and y coordinates, is designed as shown in the class diagram. It contains: Two instance variables x (int) and y (int). A default (or "no-argument" or "no-arg") constructor that construct a point at the default location of (0, 0). A overloaded constructor that constructs a point with the given x and y coordinates. Getter and setter for the instance variables x and y. A method setXY() to set both x and y. A method getXY() which returns the x and y in a 2-element int array. A toString() method that returns a string description of the instance in the format "(x, y)". A method called distance(int x, int y) that returns the distance from this point to another point at the given (x, y) coordinates, e.g.,MyPoint p1 = new MyPoint(3, 4); System.out.println(p1.distance(5, 6)); An overloaded distance(MyPoint another) that returns the distance from this point to the given MyPoint instance (called another), e.g.,MyPoint…arrow_forward
- We have a parking office class for a parking management system. It has dependencies and relations with customer, car, parking lot and parking charge classes. Explain the code by stating implementation decisions, reasons behind those implementation decisions, what you assume was hard or easy to implement, and what helped. public class ParkingOffice {String name;String address;String phone;List<Customer> customers;List<Car> cars;List<ParkingLot> lots;List<ParkingCharge> charges; public ParkingOffice(){customers = new ArrayList<>();cars = new ArrayList<>();lots = new ArrayList<>();charges = new ArrayList<>();}public Customer register() {Customer cust = new Customer(name,address,phone);customers.add(cust);return cust;}public Car register(Customer c,String licence, CarType t) {Car car = new Car(c,licence,t);cars.add(car);return car;}public Customer getCustomer(String name) {for(Customer cust :…arrow_forwardelow for each class you find a UML and description of the public interface. Implementing the public interface as described is madatory. There's freedom on how to implement these classes.The private properties and private methods are under your control.. There are multiple ways of implementing all these classes. Feel free to add private properties and methods. For each object, it's mandatory to create a header file (.h), implementation file (.cpp) and a driver. Blank files are included. The header should have the class definition in it. The implementation file should contain the implementations of the methods laid out in the header fine. And finally the Driver should test/demonstrate all the features of the class. It's best to develop the driver as the class is being written. Check each section to see if there are added additional requirements for the driver. Two test suites are included so that work can be checked. It's important to implement the drivers to test and demonstrate…arrow_forwardUtilize various programming languages to develop secure, efficient code (C++ and Java/Python) For this assignment, your implementation plan must include at least one class with public and private sections. For assistance with classes, see sections 6.2, "Using a Class," and 6.3, "Defining a Class," in zyBooks. For this assignment, we recommend using Maps (section 11.4 in zyBooks) for implementation. Maps do require precise coding syntax. However, you can choose a different implementation option. Apply industry standard best practices such as in-line comments and appropriate naming conventions to enhance readability and maintainability. Remember that you must demonstrate industry standard best practices in all your code to ensure clarity, consistency, and efficiency. This includes the following: Inserting in-line comments to denote your changes and briefly describe the functionality of the code Using appropriate variable, parameter, and other naming conventions throughout your…arrow_forward
- in java Write the Account class. The UML diagram of the class is represented below Requirements :a. Implement the class strictly according to its UML one-to-one (do not include anything extra, do not miss any data fields or methods) b. Add comments to your program (mark where data fields, constructors, getters, setters and toString() are)c. You can use the automatic generation approach for Getters, setters and toString() inEclipse.d. In getMonthlyInterestRate(), please return the monthly interest rate. DO NOT leave thismethod body blank!e. In getMonthlyInterest(), please returns the monthly interest (NOT THE INTEREST RATE),DO NOT leave this method body blank!f. In deposit() method, please deposit a specified amount to the account (Hint: balance +=depositAmount). DO NOT leave this method body blank!g. In withdraw() method, please withdraw a specified amount from the account (Hint:balance -= withdrawAmount). DO NOT leave this method body blank!h. Please use decimal to represent the…arrow_forwardSolve using OOP in Java.arrow_forwardIn java, can a polymorphic reference invoke a method that is only declared at the object's class level? If "yes", explain how.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