a.
class FitnessTracker
{
private String activity;
private int numOfMinutes;
private String date;
//default constructor
public FitnessTracker()
{
activity = "running";
minutes = 0;
date = "January 1, 2019";
}
public String getActivity()
{
return activity;
}
public int getNumOfMinutes()
{
return numOfMinutes;
}
public String getDate()
{
return date;
}
}
b.
// overloaded constructor
public FitnessTracker(String activity,int
numOfMinutes, String date)
{
this.activity = activity;
this.numOfMinutes =
numOfMinutes;
this.date = date;
}
c.
class FitnessTracker2
{
private String activity;
private int numOfMinutes;
private String date;
//default constructor
public FitnessTracker2()
{
this("running",0,"January 1,
2019"); // calling parameter constructor using this
}
// overloaded constructor
public FitnessTracker2(String activity,int
numOfMinutes, String date)
{
this.activity = activity;
this.numOfMinutes =
numOfMinutes;
this.date = date;
}
public String getActivity()
{
return activity;
}
public int getNumOfMinutes()
{
return numOfMinutes;
}
public String getDate()
{
return date;
}
}
class TestFitnessTracker
{
public static void main (String[] args)
{
FitnessTracker2 f = new
FitnessTracker2();
System.out.println("Fitness
activity : "+f.getActivity());
System.out.println("Number of
minutes : "+f.getNumOfMinutes());
System.out.println("Date :
"+f.getDate());
}
}
Output:
Fitness activity : running Number of minutes : 0 Date : January 1, 2019
Do ask if any doubt. Please upvote.
it's a JAVA program. Share Edit & Create aanmethod that tests all three overloaded methods. Save...
In JAVA 1. Create a class called Rectangle that has integer data members named - length and width. Your class should have a default constructor (no arg constructor) Rectangle() that initializes the two instance variables of the object Rect1. The second overloading constructor should initializes the value of the second object Rect2. The class should have a member function named GetWidth() and GetLength() that display rectangle's length and width. OUTPUT: Rectl width: 5 Rectl length: 10 Enter a width :...
Java program. Mike's Movie Theater is a local cinema showing the latest Hollywood hits. Create a class called Movie that stores basic information about a single movie: the title, the running time or length of the film (in minutes), the showtimes (as a single string, such as "11:00,3:15,7:30"), and the film's rating (R, PG-13, PG, or G). Include get and set methods for each; the setter for rating should check that the value is one of the four valid options...
Assighment. Creaung Java Classes with methods Note: If you have not yet completed this unit's Discussion, it is best to complete it before you begin this Assignment As studied in the Discussion, it is important to design a test plan prior to creating a class, as it will help reduce coding problems. In this unit's Assignment, you create, compile, and execute a class containing methods. Be sure to use best coding practices, such as creating a test plan, before you...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
Create a java class that implements BagInterface using singly linked data. Name this new class LinkedBag. Be sure to include a default constructor to initialize the private members of the class. Test that your code works properly. BagInterface includes the methods: public int getCurrentSize(); public boolean isEmpty(); public boolean add(T newEntry); public T remove(); public boolean remove(T anEntry); public void clear(); public int getFrequencyOf(T anEntry); public boolean contains(T anEntry); public T[] toArray();
Write an ADT named circle in java containing the following. Include data: radius (double) Include methods: A no-argument constructor A constructor that sets the data to passed values Getters and setters for each piece of data getArea (Math.PI * radius * radius … try using a Math method here) getDiameter (radius * 2) getCircumference (2 * Math.PI * radius) A toString( ) method to display the object data Include Javadoc comments for the class and every method, and generate the...
JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class. Print out the results after testing each of the methods in both of the classes and solving a simple problem with them. Task 1 – ArrayList Class Create an ArrayList class. This is a class that uses an internal array, but manipulates the array so that the array can be dynamically changed. This class should contain a default and overloaded constructor, where the default...
Create a class named Billing that includes four overloaded computeBill() methods for a photo book store. When computeBill() receives a single parameter, it represents the price of one photo book ordered. Add 8.5% tax, and return the total due. When computeBill() receives two parameters, they represent the price of a photo book and the quantity ordered. Multiply the two values, add 8.5% tax and return the total due. When computeBill() receives three parameters, they represent the price of a photo...
in java ..write all complete program from a- e 1. Given the two binary trees below: 14 16 Write a method called swapSubtrees, which swaps all of the left and right subtrees in the above binary trees. Add this method to the class BinaryTree and create a program to test this method for these 2 trees. Show the original trees and the resulting trees. Note: To test your algorithm, first create a binary search tree. Write a method called singleParent,...
Please Code in Java and follow the directions given Thanks Program required Directions .A palindrome is a string that reads the same forward and backward, i.e., the letters are the same whether you read them from right to left or from left to right. Examples: 3 a) radar à is a palindrome b)Able was I ere I saw Elba à is a palindrome e good à not a palindrome Write java program to read a line of text and tell...