Thanks for the question, here is the complete class in Java ============================================================== import java.util.ArrayList; public class MyWeek { private ArrayList<String> weekList; public MyWeek() { weekList = new ArrayList<>(); } public MyWeek(String weekName) { if (weekName == null) { throw new IllegalArgumentException(); } weekList = new ArrayList<>(); weekList.add(weekName); } public MyWeek(ArrayList<String> weeks) { if (weeks == null) { throw new IllegalArgumentException(); } weekList = new ArrayList<>(); for (String name : weeks) { if (weekList.contains(name)) { continue; } else { weekList.add(name); } } } public void insert(String week) { weekList.add(week); } public void insert(ArrayList<String> weeks) { if (weeks == null) { throw new IllegalArgumentException(); } for (String week : weeks) { if (weekList.contains(week)) { continue; } else { weekList.add(week); } } } public boolean search(String week) { if (week == null) { throw new IllegalArgumentException(); } for (String weekName : weekList) { if (weekName.equalsIgnoreCase(week)) { return true; } } return false; } public void delete(String name) { if (name == null) { throw new IllegalArgumentException(); } if (weekList.contains(name)) { weekList.remove(name); } } public void delete(ArrayList<String> names) { if (names == null) { throw new IllegalArgumentException(); } for (String name : names) { if (weekList.contains(name)) { weekList.remove(name); } } } @Override public String toString() { return weekList.toString(); } @Override public boolean equals(Object obj) { if (obj != null && obj instanceof MyWeek) { MyWeek anotherWeek = (MyWeek) obj; if (anotherWeek.weekList.size() != weekList.size()) { return false; } return weekList.containsAll(anotherWeek.weekList); } return false; } }
Design "MyWeek" class: (1) Data members: the class contains one private data field weekList. "wee...
Overloading Design a UML diagram for a TimeClock class with the following private data members: • float days • float hours The class should also have the following public member methods: • Constructor with a default that sets the data values to 0 • getDays to return the private data member days • getHours to return the private data member hours • setDays to set the private data member days • setHours to set the private data member hours •...
List of Candles Create a class called CandleNode which has fields for the data (a Candle) and next (CandleNode) instance variables. Include a one-argument constructor which takes a Candle as a parameter. (For hints, see the PowerPoint on "Static vs. Dynamic Structures”.) public CandleNode (Candle c) { . . } The instance variables should have protected access. There will not be any get and set methods for the two instance variables. Create an abstract linked list class called CandleList. This...
You will turn in a java file named "MyMethods.java". It will contain one class named "MyMethods". That class will contain three methods. These methods must be in JOptionPane and must contain: getAnInt will return a value of type int, and take as an argument a string to prompt the user. The actual prompt presented to the user should include not only the string argument, but also the information that the user may press Cancel or enter an empty string to...
Write a class that analyzes data you have stored in a text file. Your data represents the ages of the individuals in your fictitious community. The data is stored, one per line, in a text file. For example, File name: myData.txt Contents: 45 18 6.5 3 5 sdtypo# 18 10 The number of lines in your text file must fall somewhere between 20 and 100 lines. Some of the lines must hold character strings that are not convertible to integers,...
Please try to write the code with Project 1,2 and 3 in mind. And use java language, thank you very much. Create an Edit Menu in your GUI Add a second menu to the GUI called Edit which will have one menu item called Search. Clicking on search should prompt the user using a JOptionPane input dialog to enter a car make. The GUI should then display only cars of that make. You will need to write a second menu...
Exercise 1 Adjacency Matrix In this part, you will implement the data model to represent a graph. Implement the following classes Node.java: This class represents a vertex in the graph. It has only a single instance variable of type int which is set in the constructor. Implement hashCode() and equals(..) methods which are both based on the number instance variable Node - int number +Node(int number); +int getNumberO; +int hashCode() +boolean equals(Object o) +String toString0) Edge.java: This class represents a...
PART B: DATE BOOK A classic computer application is the electronic date book: a list of daily events stored in a calendar. Write a Java program that can be used as a simple date book. The date book will use a separate array for each month of the year, with one array entry for each day in the month (0 = first day of the month, 1 = second day of the month, etc.). The date book is "simple" because...
An array of class objects is similar to an array of some other data type. To create an array of Points, we write Point parray [4]; To access the object at position i of the array, we write parray [i] and to call a method on that object method, we write parray [i]. methodName (arg1 , arg2 , ...) ; To initialize an array of objects whose values are known at compile time, we can write Point parray [4] =...
In Java, Implement a class MyArray as defined below, to store an array of integers (int). Many of its methods will be implemented using the principle of recursion. Users can create an object by default, in which case, the array should contain enough space to store 10 integer values. Obviously, the user can specify the size of the array s/he requires. Users may choose the third way of creating an object of type MyArray by making a copy of another...
Design a class named BankAccount that contains: 1. A private int data field named accountId for the account. 2. A private double data field named accountBalance for the account (default 0). 3. A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. 4. A private Date data field named dateCreated that stores the date when the account was created. 5. A private int data field named numberOfDeposits...