Related questions
- Complete the following piece of java code (MyDate class). The semicolon after each method must be replaced with a set of curly braces, in which the instructions for the method are placed.
- Think of one error and add error handling to your
program - Create a class diagram for the MyDate class.
- Create a test class to test mydate (main class with a main method)
public class MyDate {
/* If no arguments were provided then default the date January 1st, 1970 (epoch time). */
public MyDate();
/* Creates a new MyDate from an existing MyDate */
public MyDate( MyDate date);
/* Creates a new MyDate from a day, month, and year */
public MyDate( int day, int month, int year);
/* Returns the day of the month for this MyDate */
public int getDay();
/* Returns the month of the year for this MyDate */
public int getMonth();
/* Returns the year for this MyDate */
public int getYear();
/* Returns true if this MyDate represents a date in a leap year */
public static boolean isLeapYear( int year );
public static int getLastDayOfMonth( int month, int year );
/* This internal method returns the calculated Julian number for the provided day, month, year
* This method is static, as it does not require a MyDate object to perform its computation
*/
}
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images
- #this is python programing #topic: OOP Question 2 Design a class called Flower with the instance variables so that after executing the following line of code the desired result shown in the output box will be printed. [You are not allowed to change the code below] #Write your class code here flower1 = Flower() flower1.name="Rose" flower1.color="Red" flower1.num_of_petal=6 print("Name of this flower:", flower1.name) print("Color of this flower:",flower1.color) print("Number of petal:",flower1.num_of_petal) print("=====================") flower2 = Flower() flower2.name="Orchid" flower2.color="Purple" flower2.num_of_petal=4 print("Name of this flower:",flower2.name) print("Color of this flower:",flower2.color) print ("Number of petal:",flower2. num_of_petal) #Write the code for subtask 2 and 3 here Output: Name of this flower: Rose Color of this flower: Red Number of petal: 6 ===================== Name of this flower: Orchid Color of this flower: Purple...arrow_forwardPYTHON CLASSES AND OBJECTarrow_forwardGiven the following Date class public class Date { private int year; private int month; private int day; public Date() { /** Implementation not shown */ } public Date(int year, int month, int day) { /** Implementation not shown */ } public void print() { /** Implementation not shown */ } } assuming that months in the Date class are numbered starting at 1, which of the following code segments will create a Date object for the date September 20, 2020 using the correct constructor? Date d = new Date(); Date d = new Date(9,20); Date d = new Date(9,20,2020); Date d = new Date(2020,9,20); Date d = new Date(2020,20,9);arrow_forward
- Write in Javaarrow_forwardCLASS NAME List the instance variables in the constructor. List the methods in the class. - indicates private CLASS NAME List the instance variables in the constructor. List the methods in the class. The second row of the UML diagram lists the instance variables in the constructor. For example -name: string o o name is the variable name o string is the data type of name + indicates public o getName is the method name o o string is the return data type Java.util. The third row of the diagram lists the methods in the class. For example, +getName(): string empty parenthesie indicate nothing is sent to the method.arrow_forwardPlease help me with this using java. And comment the code The following is some code designed by J. Hacker for a video game. There is an Alien class to represent a monster and an AlienPack class that represents a band of aliens and how much damage they can inflict: class Alien { public static final int SNAKE_ALIEN = 0; public static final int OGRE_ALIEN = 1; public static final int MARSHMALLOW_MAN_ALIEN = 2; public int type; // Stores one of the three above types public int health; // 0=dead, 100=full strength public String name; public Alien ( int type , int health, String name) { this.type = type; this.health = health; this.name = name; } } public class AlienPack { private Alien[] aliens; public AlienPack (int numAliens) { aliens = new Alien[numAliens]; } public void addAlien(Alien newAlien, int index) { aliens[index] = newAlien; } public Alien[] getAliens() { return aliens; } public int calculateDamage() { int damage = 0; for (int i=0; i < aliens.length; i++) { if...arrow_forward
- Bank Accounts (Use Python) Write a program that accepts bank transactions and prints out the balance of an account afterwards. PROGRAM DESIGN Create a class named bankAccount. A bank account should have the following attributes: accNumber, balance, and dateOpened. This class should also have the option to do the following transactions: deposit, withdraw and drop. Initially there is only one bankAccount active in the program, with a balance amount of 1515, and was opened back in 10/01/1987. Depositing adds to a current bankAccount’s balance, while withdrawing – does otherwise. Dropping would equate the current balance to zero. Refer to the following class diagram for more details about the current bankAccount: bankAccountaccNumber = 1balance = 1515dateOpened = "10/27/1987" deposit(dep)withdraw(wd)drop(accNumber) INPUTThe input would be a string that contains the following data: the transaction to be done (dep – for deposit, wd – for withdraw and drop – for drop), the accNumber, and...arrow_forward2. Add a constructor for Animal class shown. The constructor should pass in a string parameter named "sound". 1 using System; 2 3 public class Animal 4 { 5 public string Sound { get; set; } public void Speak() { Console.Writeline("The dog says " + Sound); } 10 11 } 12 13 public class Program 14 { public static void Main() { 15 16 17 18 } 19 } A 00arrow_forwardWrite a python code for both 1 and 2 use random inputs for each variablearrow_forward
- javaarrow_forwardT/F 3. Any Java class must have a main method, which is the first method that is called when the Java class is invoked.arrow_forwardJava- Suppose that Vehicle is a class and Car is a new class that extends Vehicle. Write a description of which kind of assignments are permitted between Car and Vehicle variables.arrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY