How To Create And Link Two Classes
Apr 16, 2014
i have tried moving the
//create line
Point beginOfLine = new Point(point1, point2);
//ask user for second pair of coordinates
System.out.print("Enter the coordinates for X2 or <Random> or <Exit>:");
userInput=keyboard.nextLine();
code part to another class but nothing..this is what a second class should be doing
1 - Write a java class called Point to represent a 2-D point (With x and y)
- The constructor should take the x & y as double
- The class should have accessor / mutator methods for all coordinates
2 - Write a java class called Line to represent a line (with a starting point and an ending point)
- The constructor arguments are the start and end points
//import utilities to be used in the program
import java.util.Scanner;
import java.util.Random;
public class Point {
//declare variables
private double pointX, difX;
private double pointY, difY;
[code]....
View Replies
ADVERTISEMENT
Dec 15, 2014
I'm trying to get to grips with the AndEngine, so I've recently gotten hold of their Cookbook, but there's a section that's confusing. I'm using the Eclipse IDE with the section is asking that I create two inner classes to an ObjectFactory class. I'm not sure if what it wants me to do is doable in java or specifically in Eclipse. This is the section of code the book is asking me to create.
Java Code:
package com.example.helloworld;
public class ObjectFactory {
public static LargeObject createLargeObject(final int pX, final in pY){
return new LargeObject(pX,pY);
}
public static SmallObject createLargeObject(final int pX, final in pY){
return new SmallObject(pX,pY);
}
} mh_sh_highlight_all('java');
Now this is returning errors that I should declare these two as individual classes, but I feel like I am missing something. Earlier the book asks you to create this BaseObject class.
Java Code:
package com.example.helloworld;
public class BaseObject {
@SuppressWarnings("unused")
private int mX;
@SuppressWarnings("unused")
private int mY;
[code]...
It then mentions that the two classes LargeObject and SmallObject are inner classes of BaseObject and extends this class. The ObjectFactory class is meant to determine which subtype of the base class that needs, as well as define the objects properties.
View Replies
View Related
Feb 14, 2015
For class, we need to create a word game using classes and objects.
The game is played in rounds. The player is presented with a word that is missing letters. The player has to fill in the missing spaces with their letter guesses. The words presented are chosen with a random number generator which has been provided for us. At the end of the game, the player is shown their score.
In steps, I have to:
-Welcome the player.
-Present the puzzle.
-Allow the player to fill in the blanks.
-Have the program check responses for correct/incorrect input.
-End the game if they have three misses, or continue if they complete the puzzle.
Now, to start, I have a class for the number generator, a class to store the array of 25 words, and a class for the game itself.
View Replies
View Related
Apr 14, 2014
I am new a creating GUIs and am not quite sure how to correctly make one. I have done the inheritance parts, and created two extra appliances: a washer and dryer. Now Creating the GUI ....
Here are the instructions to my project.
Introduction to GUIs (+ some inheritance)
For this assignment, you are going to create a user interface that interacts with the setters and getters of some classes that you will create.
First, create an abstract class called Appliance. This abstract class should have two attributes (dealing with household appliances) and two abstract methods called turnOn() and turnOff(). These methods should return void.
Then, create two subclasses of Appliance that represent household appliances (like a Refrigerator or Stove ((don't use those!))). These subclasses should have two attributes that are specific to the various appliance. Each subclass should implement the turnOn() and turnOff() methods. These methods should print to the command line some information about the appliance as it turns on and off.
Now, the fun part! Create a GUI interface!
Your window should have two panels: one for each appliance subclass. Each panel should have 4 textboxes (with appropriate labels) to receive/display information that correspond to the 4 attributes (2 from Appliance and 2 from the subclass) for each subclass.You also need 2 buttons on each panel: A Get button and a Set button.
When the Get button is pressed, the text boxes should be filled with the information from the instantiated object of the appropriate subclass. When the Set button is pressed, the object should then contain the information contained that the user has altered.
In your main method, you should create an object of each subclass, and prefill it with information (either using the constructor or the setters), then display your GUI. You should now be able to get and set the information for your objects from the GUI.
At least one of your attributes for each subclass should be numeric
Note that you will need to handle incorrectly formatted input (You can use exception handling to do this if you want to. Wrapper classes also will work)
If there is text in the boxes when the "Get" button is pressed, it should be overwritten by what is in the object. Remember that these two panels should both be on screen at the same time.
You don't need 2 different windows, one window: 2 panels.
View Replies
View Related
May 26, 2014
The JTable that I'm using in my program fetches its value from the database. Now one of the fields contain the link item. I basically want it to be clickable so that once the user clicks on this link then he is directed to the desired webpage. I've tried to implement this in my code but somehow nothing seems to work.
Java Code:
public class JTableButtonMouseListener extends MouseAdapter
{
private final JTable table;
public JTableButtonMouseListener(JTable table) {
this.table = table;
[Code] .....
View Replies
View Related
Mar 9, 2015
I want to connect netbeans to netlogo. I have a class: NetLogoConnection I want to call the class when I click on OK btn in my GUI. The codes are as following:
XML Code: import org.nlogo.app.App;
public class NetLogoConnection {
public static void main(String[] argv) {
App.main(argv);
try {
java.awt.EventQueue.invokeAndWait(
new Runnable() {
public void run() {
[code]....
View Replies
View Related
Sep 19, 2014
In my jsp page , functionality is their to change the status of the employee, so i want that if i click on activate it should change the link to the deactivate and when i click on deactivate it should change to activate. How can i do that?
View Replies
View Related
Feb 10, 2014
I want to display the data on edit link according to Id no .For Ex I have data on the table below
IDName Emp ID Dept Edit
1xyz 3425 abcd Edit
On Edit link display the data according to ID number. How can i write the code.
View Replies
View Related
Dec 17, 2014
What's wrong ? I'm trying to send parameters in a link so I can get this parameter (an id) and get all the forum-threads that are relatives to this parameter. Because I can't set attributes in a link. Or can I ?
<c:out value='<a href="<c:url value="threads.jsp">
<c:param name="idSub" value="${subforum.idsubforum }"/>
<c:param name="subName" value="${subforum.name }"/>
</c:url>">${subforum.name}</a>' escapeXml=""/>
does not work but I read it's not used in html. I'm really lost on this one.
View Replies
View Related
Dec 8, 2014
How to copy the target of a link? I am using Apache's FileUtils class. I have tried the following and it only copies the link, not the target:
import org.apache.commons.io.FileUtils;
import java.io.File;
public class Copier {
public static void main(String[] args) {
File sourceFile = new File("C:/Demo/sourceDir/a_link.lnk");
File destinationDirectory = new File("C:/Demo/destinationDirectory");
FileUtils.copyFileToDirectory(sourceFile, destinationDirectory);
}
}
View Replies
View Related
Mar 17, 2014
In our product, we have many different of "roles". Some of these roles are defined in our dataload JSON and others are defined in our bootstrap SQL.
Throughout our code, we refer to specific roles by name. We want to provide some sort of documentation for these roles when we mention them in documentation, but we don't want to maintain multiple definitions/descriptions for these roles (ie: we don't want one for documentation and a separate one for execution).
Any way we can "expose" the role definitions to the documentation? The best thing I've got is adding some sort of "export script" to each generation of the javadocs, but I don't have a clue how, or if, that can even be done...
View Replies
View Related
Dec 17, 2014
I'm working on a simple site for my friend, and he asked me to link to his other site. I need to have the link to a specific search. For example, if I search for "Heathrow," I need to be able to link a button on the other site so that it can be clicked and directed to the search results on this page. Problem is that this is apparently all Java (which I know nothing of) and how to just copy a link to the results page.
View Replies
View Related
Sep 30, 2014
I need to design a gui that will find out all the dead symbolic link from the directories. And I used the logic and syntax I find out in java orcle docs. And If I will give the direct path name of the symbolic file then it is running fine with the output and enable to find the smbolic link is active or not. Now the real problem is that , I want that logic of detection should run out through the complete files and subdirectories of the directory. So Then I used the tree walk concept to transver through the complete file system of the directory and embed the logic of the detection inside it for detection of the dead symbolic link. But now it showing erroe which is not approacable for me.
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class To_Transver {
[Code]...
View Replies
View Related
Jan 31, 2014
I have a tooltip implemented on a main page, but when you click the link tooltip box gets stuck on next page
<h:outputText value="#{it.get(newItem.strCampoNombre)}" rendered="#{newItem.strCampoTipo == '1' or newItem.strCampoTipo == '5' or newItem.strCampoTipo == '4' or newItem.strCampoTipo == '9' or newItem.strCampoTipo == '10' or newItem.strCampoTipo == '11'}" />
<h:outputText value="#{it.get((newItem.strCampoToolTip))}" rendered="#{newItem.strCampoTipo == '8'}" />
<rich:tooltip styleClass="tooltip" layout="block" rendered="#{newItem.strCampoTipo == '8'}" showDelay="500" onhide="false" hideEvent="mouseleave">
<span class="wrap"> <h:outputText value="#{it.get(newItem.strCampoNombre)}" /> </span>
</rich:tooltip>
problem.png
I tried to change the tooltip parameter but didnt find the solution.
View Replies
View Related
Jan 2, 2015
I have following code to populate a dynamic menu from categories retrieved from database
<jsp:useBean id="category" class="category.CatBean" scope="application"></jsp:useBean>
<c:if test="${applicationScope.cartList == null}">
<c:set var="catList" value="${category.categoryList}" scope="application"/>
</c:if>
<div id="categoryBrowse"><label>Browse by Category</label></div>
<div id="cssmenu">
[Code] ....
It works fine. But every time I click on a link on the menu, it duplicates the whole menu.
View Replies
View Related
Jun 14, 2014
Say I have two classes, Author and Book, and I have 2 author objects and 10 book objects. I would like to know how to do two things:
1) Make some sort of connection that makes clear that author X wrote books A, B and F.
2) Call a method from a book object that is connected to an author.
Seeing as I don't know which books will be connected to an author, is there some way to call a method of an object bases on a variable object name? Something like call the getFirstPage() method for every book that is linked to author X?
View Replies
View Related
May 3, 2014
When I try to run my runnable jar file, it wont do anything. And when I try to run it from the console, it says
"java.lang.UnsatisfiedLinkError: no LWJGL in java.library.path..."
How do I fix this?
I've specified the path by properties > Libraries > lwjgl.jar > Native Library Location > .... And I chose the right paths. But I still get that java.lang.UnsatisfiedLinkError.
It says I'm getting an error on line 34 which is:
appgc = new AppGameContainer(new Game(gamename));
My whole main class is:
package net.battleboy;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Game extends StateBasedGame {
public static final String gamename = "Battle Boy 1.0 ALPHA";
public static final int menu = 0;
public static final int play = 1;
public static final int settings = 2;
[Code] .....
View Replies
View Related
May 15, 2014
I put link using JQuery on Home Page,
<div class="list_block1" >
script type="text/javascript" src="js/jquery.leanModal.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" />
<link type="text/css" rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/postoffer.css" media="all"/>
<div class="container">
<a id="modal_trigger" href="#modal" class="btn">Click here to Login or register</a>
<%
[Code] ....
View Replies
View Related
Feb 5, 2011
How to Expire the sending link to a mail after particular period of time
View Replies
View Related
Jul 7, 2014
i have a problem with navigating from a link in a primefaces tree menu to a specific page. The explanation is the following: I have a template with the following code :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
[code]....
i had to put a "*" in the from-view-id tag to be able to navigate to the pages specified with the navigation cases. If i put /templates/leftMenu.xhtml insted of * then the navigation doesn't work and i get the error "WARNING: JSF1064: Unable to find or serve resource, /deleteDepartment-page.xhtml."
View Replies
View Related
Jan 21, 2015
How to add select case
when to_char(trunc(TO_DATE ('03-APR-2015','DD-MM-YYYY'), 'mm'), 'FMDAY') = 'SUNDAY'
then to_number(to_char(TO_DATE ('03-APR-2015','DD-MM-YYYY'), 'W'))+1
else ceil((to_char(TO_DATE ('03-APR-2015','DD-MM-YYYY'), 'dd') + 1 - to_char(next_day(trunc(TO_DATE ('03-APR-2015','DD-MM-YYYY'), 'mm'), 'SUNDAY'), 'dd'))/7)+1
end week_no
from dual
query to Eclipse Link CriteriaBuilder
I am able to add distinct(to_char(sum(datecolumn,number),'W-MM-YYYY')) like
Expression sum = cb.sum(CriteriaQueryUtils.getPath(rt, breakupFields), cb.literal(miliSecToAdd));
Expression<String> literal = cb.literal("W-MM-YYYY");
Expression<String> functionselectclause = cb.function("TO_CHAR", String.class, sum,literal);
return query.select(functionselectclause ).distinct(true).where(p).orderBy(orders);
But need to know how to add case when else to CriteriaBuilder...
View Replies
View Related
Mar 25, 2013
Trying to deploy the application with webService project fails with below error
weblogic.j2ee.dd.xml.AnnotationProcessException: [EJB:015001]Unable to link class oracle.apps.scm.productCollaboration.common.businessClasses.businessClassesService.applicationModule.
server.BusinessClassServiceImpl in Jar /scratch/software/mw_local/FMWTOOLS_11.1.1.7.0_GENERIC_121222.1001.2_PATCHES4FA_11.1.1.7.0_PLATFORMS/jcyril/mw_home_standalone/user_projects/domains/fusion_domain/servers/AdminServer/upload/ProductLifecycleManagementApp
[Code] ....
View Replies
View Related
Apr 18, 2014
How do you call classes within other classes? Or can you only call classes through the main?
View Replies
View Related
Feb 14, 2015
I'm doing an aggregation exercise that's suppose to find the volume and surface area of a cylinder. What I'm trying to do is pass values from one class, to a second class, and that second class passes values to a third class.
This may be a clearer explanation: The first class is the main program which sends values to the second and third class. The second class is used do calculations for a circle (a pre-existing class from another assignment). The third class grabs the values that the second class calculated and calculates those values with the one that was passed from the first class to the third class. The first class then prints the outcome.
Problem is when the program gets to the third class, it just calculates the value from the first class with the default constructor from the second class. It's like the second class never received the values from the first class. I think I'm missing a step, but I don't what it is.
First Class:
package circle;
import java.util.Scanner;
public class CylinderInput
{
static Scanner in = new Scanner(System.in);
public static void main(String[] args)
{
//user defined variable
[Code]...
View Replies
View Related
Oct 30, 2014
Alright, I don't understand how to link my compress method to my return statement method "getPText". Also in my compression I only want it to compress for 3 or more consecutive letters.
import java.util.Scanner;
class RunLengthCode {
String pText;
String cText;
void setPText(String PText) {
pText = "";
}
[Code]...
View Replies
View Related
Aug 17, 2014
I have a jsp page that has a url that looks like this
<p><a href="SubscriptionController?action=subscriptionlist">Administrator Subscription Maintenance List</a></p>
Now I want to essentially slide through that page by using jsp:forward instead of the link
<jsp:forward page="/SubscriptionController?action=subscriptionlist" />
Problem is, the link invokes the doGet method of my servlet and the jsp:forward invokes the doPost. Is it possible to use jsp:forward and specify doGet somehow?
View Replies
View Related