I'm learning about abstract classes and I have to create an abstract auto class with make and price of a car, then two classes with a different type of car, and finally a main to use them. Everything seems to work and when I run it it's fine but I do get an error on the main that I'm not using the local variable buick1 and acura1.I'm curious because, while it runs for me, I want to make sure I'm doing it right and don't know of another way to do the output than this. I've put all four classes but the issue is on the last one (5 and 7).
public abstract class Auto
{
protected String makeCar;
protected double priceCar;
public Auto(String newMake)
{
makeCar = newMake;
I am working on a project named as "Auto Click and Populate". This is link is like online feedback form / surveys which we program. I have a link with me which is mentioned below and there will be a counter box which will hit the link that much number of times.
Inputs:
-A text box having this link. -A numeric box having counter number i.e. the number of times the link should be processed. -A button named as process which will INITIATE the process.
Now say if I input 10 into the numeric box; the attached file contain link should be processed 10 times and the question which is coming on the link should be answered randomly out of the options which are present. For ex: When you will hit a link; the first question will be gender in that 3 options are present "Male", "Female" and "Prefer not to answer"; either of 1 out of 3 should be punched automatically and proceed automatically ahead. The punch(es) will be stored in database which is maintained at my end.I have done research and till now found the code for auto click only and not for auto process.
I know whats the interfaces and abstract class and also know that difference between interface and abstract class,but here my doubt is eventhough abstract class more advantage than the interface,then why should we use interfaces and when?
I passed my abstract class private final reference to another concrete class and I used abstract class reference as parameter to that concrete class constructor and in my main method and null to that parameter then only that program executes correctly...i placing my code below ..if there is any error tell me where is error occurring then i will check my code...i think my code is right but little bit doubt abstract class concept.
{ } class concept1 extends concept { private final concept parent; public concept1(concept aparent) { parent=aparent; System.out.println(parent); } public static void main(String args[]) { //concept p=new concept1(null); concept c=new concept1(null); }}
I am under the assumption that In the return statement of getReciprocal() method(of the following code), a temporary Number object is created to hold the result of the calculation.
My question is, Number is an abstract class and we are only able to create reference of an abstract class not an object. But then how a temp Number object is created and returned?
class Gen<T extends Number>{ T ob; Gen(T ob){ this.ob = ob; } Number getReciprocal(){ // Number is abstract class
What this interface inside that abstract class does. Looking for some examples to how can i use it ....
public abstract class Expression { public abstract String toString(); public abstract SimpleExpression evaluate(); public void show() { System.out.println(this + " = " + evaluate());
public class Class1 extends AbstractClass { //stuff } public class Class2 extends AbstractClass { //stuff }
within another class I have a private variable with the type of the Abstract class, and within one of the methods I assign an object to the the variable like this:
public class Test { private AbstractClass temp; public testMethod(){ Class1 anObject = new Class1(); temp = anObject; } }
How do I create an instance of a class in a method?
I am a bit rusty whenever I think of instances. I always think of main method and objects when I see instance which gets me confused on what to do when I am not in a main method. The example:
I have a abstract class, School, and inside School I have some methods that must preform some action on an instance. For example, there is a move() method that must move the instance of School. Another method named, personOld(), which returns whether or not an instance of School surpassed some determined age.
I have a simple classes here one is interface and another one is abstract class when i try to compile them abstract class is givving compilation error.
public interface MyInterface{ public void getName(); public void getName(String s); } public class HelloWorld{} abstract class SampleClass{
In the class below I'm trying to create a class that will accept dates in various formats and create a range. The first constructor is easy because I send it the begin date and end date as Date objects. Now I want to send a month(and year) in a constructor and derive the begin and end dates from it. In my constructor that accepts the month/year I need to put the this(startDate, endDate) at the top to be allowed, but the parameters are not built yet.
package com.scg.athrowaway; import java.util.Calendar; import java.util.Date; public class DateRange { private Date startDate; private Date endDate;
How to create object for "class B" and call the "function_B" from other different class D where class D has no connection with class A? Here is my program.
public class A(){ void print(){} } class B{ void function_B(){} } class C{ void function_C(){} }
Here, A, B, C are in the same package. But class D is in different package.
Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. There is also a MyDate class as explained below. A person has a name, address, phone number, and email address. A student has a status (freshman, sophomore, junior, or senior). Define the status as an integer which can have the value 0 (for "Freshman"),
1 (for "Sophomore"), 2 (for "Junior"), and 3 (for "Senior"),
but don't allow the status to be set to any other values. An employee has an office, salary, and dateHired. The dateHired is a MyDate field, which contains the fields: year, month, and day. The MyDate class does not explicitly inherit from any class, and it should have a no-arg constructor that sets the year, month, and day to the current year, month, and day. The MyDate class should also have a three-argument constructor that gets three int arguments for the year, month and day to set the year, month and day.
A faculty member has office hours and a rank. Define the rank as a String (for values like "Professor" or "Instructor"). A staff member has a title, which is also a String. Use data types for the fields as specified, or where one is not specified, use a data type that is appropriate for the particular field. Write a test program called TestEveryone.java that creates a Person, Student, Employee, Faculty, and Staff object, and invoke their toString() method (you don't need to call the objects' toString() method explicitly).
Note: Your MyDate.java class is the object class that your dateHired field is created from in the Employee.java class.
Do not use the Person, Employee or Faculty classes defined on pages 383 and 384 of the book. Create new ones.Here is the code I have so far concerning the employee and MyDate.
public class Employee extends Person { private String office; private double salary; //private MyDate dateHired; //7 argument constructor for employee public Employee(String name, String phoneNumber, String email, String address, String office, double salary /*MyDate dateHired*/) { super(name, phoneNumber, email, address);
The assignment is to create a SmartString class that implements a SmartStringInterface class (created by professor) and implements a few methods. We are basically taking a string and then taking various substrings and inserting, deleting them and undoing changes as well. Here are the methods in the interface to use along with the parameters.
public interface SmartStringInterface { public void insert(int pos, String sstring); public void delete(int pos, int count); public void undo(); public String toString();
The Undo is supposed to be able to be called multiple times (to be tested using a driver program that we must create) but the part that's got me is that the changes are only supposed to be stored. Currently, I am storing the "new" string after each change onto a stack, so that undo can just pop off the stack and it will revert to the previous string. Professor said that was wrong, so I don't know how to do it. Here is what I have so far (some of the code we have is using default StackADT stuff from our book, so if you need that I can post as well. You can see in the undo method where I currently save the string. We can use multiple stacks if needed, but the less the better. Must use at least 1. The exception code is already coded for us in another file also. I am only having to code these methods and the driver to test.
import java.util.Arrays; public class ArrayStack<T> implements StackADT<T> private final static int DEFAULT_CAPACITY = 100 private int top; private T[] stack;
How to write a program which will automatically correct the parts of speech of a document.
Example: say in my document I have My/PRONOUN name/PRONOUN is/VERB Jhon/NOUN. He/PRONOUN is/VERB going/ADJ to/PREPOSITION school/NOUN
Now I need to change My/PRONOUN name/NOUN is/VERB Jhon/NOUN. He/PRONOUN is/VERB going/VERB to/PREPOSITION school/NOUN...How to do using java. The document may contain 100 lines tagged with parts of speech.
I'm new to Java and I have an assignment to create a Sphere class that will allow you to create Sphere objects using the code below. Then create a program called SphereTester that prompts the user for the radii of two spheres in meters. The program should display which sphere is larger and by how many cubic meters and display only four digits after the decimal point. I have the sphere class given to us for the assignment which is this:
Java Code: public class Sphere { // instance variable (i.e., a field) private double radius; // constructor for the Sphere class public Sphere(double r) { radius = r;
I need my Java program (I'm working in Eclipse if it matters) to detect if an image is a portrait or a landscape, but since i am directly downloading them from my camera they only have it written somewhere in metadata, the image width and height is the same for landscape and portrait. I have the rotation code and the rest of the program working, but I need to somehow get a variable (for example integer one) to tell me if it is a portrait or a landscape image. I tried getting to the metadata but my Eclipse decided that import com.drew.metadata.Metadata; cannot be resolved.
BufferedImage image = ImageIO.read(new File(imagePath, imageName)); and after I get the variable "orientation" it looks like this
int orientation = ???; BufferedImage newImage = oldImage; if (orientation>1){ newImage = rotate(oldImage); }