|
no sir i m asking how can i relate my theory examples to industry level so here many are working thats why i asked sir?
|
|
|
|
|
//hierarchial inheritance
class Polygon
{
double height;
double width;
public void set_values(double a,double b)
{
height=a;
width=b;
}
}
class Rectangle extends Polygon
{
double area()
{
return height*width;
}
}
class Triangle extends Polygon
{
double area()
{
return (height*width)/2;
}
}
class AreaClass
{
public static void main(String[] args)
{
Rectangle obj1=new Rectangle();
Triangle obj2=new Triangle();
obj1.set_values(10,10);
obj2.set_values(10,10);
//obj1.Rectangle();
//obj1.Triangle();
System.out.println("Area of rectangle is "+obj1.area());
System.out.println("Area of Triangle is "+obj2.area());
}
}
// so sir i know the concept but i m not able to get how exactly this will be applied in industry so please provide some example then i will think and try to solve that kind of problems
|
|
|
|
|
SSHASHIDHAR wrote: how exactly this will be applied in industry Impossible to say, since the code without detailed explanation does not mean a lot. What problem is it supposed to solve?
|
|
|
|
|
Sir actually i have taken that as one simple inheritance program so i can write such theoretical programs but i wanted to know how in industry that inheritance is helpful i mean if u give some clarity then i can able to solve.
|
|
|
|
|
SSHASHIDHAR wrote: if u give some clarity then i can able to solve. Solve what? You have not defined a problem. As far as using your code in "industrial level" situations, it may well be useful, but you need to find the problem first, before you can apply the code to it.
|
|
|
|
|
I have an existing MVC application that uses the following Dispatcher:
<servlet-mapping>
<servlet-name>SpringDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
What I did was under the WEB-INF/views directory add a menu.jsp file to be the new startup jsp.
/SpringMvcJdbcTemplate/WEB-INF/views/menu.jsp
New menu.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<div align="center">
<h1>Main Menu</h1>
<h3><a href="listContact">List Contacts</a></h3>
</div>
</body>
</html>
Now what I did is change the initial "/" RequestMapping controller method to look like the following:
@RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView menu(ModelAndView model){
model.setViewName("menu");
return model;
}
Now I feel that everything should work but when I run the application I receive the following page errors:
HTTP Status 404 - /SpringMvcJdbcTemplate/WEB-INF/views/menu.jsp
type Status report
message /SpringMvcJdbcTemplate/WEB-INF/views/menu.jsp
description The requested resource is not available
I am not sure what I am doing wrong. Can anyone help?
|
|
|
|
|
I was doing something dumb. I misspelled "menu" as "meun". Renamed and now all is better.
|
|
|
|
|
<b>Code Design for turn based game:
I am raising this question to know the alternatives for the implementation of turn based game like poker,
Where every player gets userturn of x seconds, when the user takes the action the turn goes to next player and this continues until some condition of money betting is met.
Currently i have one design in my mind where i am defining a run() method of thread having a while loop which keeps on checking the state of the game and keeps passing the userturn until the all states show up and game ends.
I am looking for any alternative of this design, if possible.
Psuedo code goes here
gameStates enum : Ante, Preflop,Flop, Turn, River, Show
</b>
run()
{
// implementing run method of thread class
do
{
switch(gameState)
{
case Ante:
//deduct ante and distribute holecards to players
//update money pot
//change the game state to preflop
//send user turn to a player of x seconds
break;
case Preflop:
if(allPlayersBetMatch())
//distribute community cards
//change the game state to flop
else
//send userturn to players
break;
case Flop:
if(allPlayersBetMatch())
//distribute community cards
//change the game state to turn
else
//send userturn to players
break;
case Turn:
if(allPlayersBetMatch())
//distribute community cards
//change the game state to river
else
//send userturn to players
break;
case River:
if(allPlayersBetMatch())
//change the game state to show
else
//send userturn to players
break;
case Show:
//process holecards of active players
//show winners
// reset all
break;
}
}
while(runStateMachine==true)
//run method ends here
}
allPlayersBetMatch()
{
//process current user action who was given the userturn.
//returns true if all players have thrown equal money into the pot,
//else case,someone has raised the bet so find active player and send userturn of x seconds and wait for his action until turn expires
}
|
|
|
|
|
I created a new Spring MVC Dynamic web project with eclipse. I created a controller class .java file and cut and pasted code from an example project into my new class. Now in the new Controller code I have import libraries in the pasted in code. For example:
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
Now, how do I go about actually add this import libraries to my project so that they will be included in the Spring MVC application? I am currently using Eclipse to develop the application.
modified 30-Oct-15 16:43pm.
|
|
|
|
|
Have you installed the jar files on your system? If so you just need to add their location in eclipse: Go to Project -> Properties ->, select "Java Build Path" and the Libraries tab, and add the details there.
|
|
|
|
|
Message Removed
modified 30-Oct-15 16:27pm.
|
|
|
|
|
Hi, Java Friends
I'm an software engineer from China(I apologize for my ugly English), I used my spare time to develop an open source framework since 2008, after 7 years, it's has been finished and the first version is pulibshed on github. Its name is "BabyFish"
Please view
https://github.com/babyfish-ct/babyfish
to know more(The framework is also uploaded to the Maven Central Repository, but demo projects and document can only be accessed from github).
Functionalites
This framework is an Object Association Management framework(Let's call it OAM), it can be split to 2 parts
(1) Java Part
(a) Event combiner: support .NET style event notification mechanism.
(b) Typed-18N: support strong type "18N" which can report the I18N errors at compilation time.
(c) X-Collection-Framework: Enhance the Java Collection Framework. The most important functionality is "Unstable Collection Elements", element/key can be
modified after it has been added into set(map) because the corresponding sets/maps will be adjusted automatically when it's changed.
(d) MA-Collection-Framework: Enhance the X-Collection-Framework to let collections support modification notification like the trigger of database. The most
important functionality is "Bubbled Event", If the modification event has been triggered by iterator of view(eg: List.subList, SortedMap.subMap), it will bubbled to
its parent view, util the original root collection triggered the event.
(e) ObjectModel4Java: ObjectModel(Both ObjectModel4Java and ObjectModel4JPA) is the most important functionality of this framework, a powerful API to create
Java model classes, it supports the smart bidirectional association between objects. When one side bidirectional association is changed, the other side will be
notified and adjusted automatically. User only need to declare some annotations and all the functionalities will be implemented by the byte-code generated dynamically
in runtime.
(2) JPA/Hibernate Part
(a) ObjectMode4JPA: Enhance ObjectModel4Java. let ObjectModel support JPA entity classes.
(i) Replace the lazy proxy and lazy collection of Hibernate to support ObjectModel with laziness management.
(ii) Support Maven plugin to change the byte-code of entity class at compilation time, programmer only need to write the simple JPA entity classes, and
complex code for the ObjectMode4JPA can be injected into entity classes automatically during compilation.
(b) BabyFish-JPA-Criteria: A smarter implementation of JPA Criteria, it supports more functionalities, and it can optimize the generated JPQL.
(c) QueryPath: A functionality learned from "ADO.NET Entity Framework", for dynamic fetch and sort, query path can be used to to fetch the lazy properties with
unlimited depath and breadth, sort query result and sort object collection associations. It can be decided by UI Layer dynamically, then dispatched to Business Logic
Layer, and finally dispatched to the Data Access Layer.
(d) DistinctLimiQuery: Enhance the Oracle Dialect of Hibernate to resolve a problem of Hibernate, In hibernate, when paging query(with firstResult/maxResults)
contains collection fetches, hibernate has to query all the data and do the paging filter in memory. This functionality can resolve this p
|
|
|
|
|
can anyone send the display message.jsp code..am using the struts .....help me
|
|
|
|
|
Sorry no, this site does not provide code to order. But if you ask a proper question then people will try to help you.
|
|
|
|
|
@Richardd MacCutchan........haiii sir this site does not allow me to download here .....please can u mail to mvmohan19@gmail.com.....its my request
|
|
|
|
|
|
Here is my CV - short version , I am not applying for a job
Wrote my first program in assembly in 1973
...
currently enjoying life as retired OF and writing code for ATmel SAM3x8E ( I do not want to advertise here the real hardware, they do not deserve that ).
I am frustrated with rudimentary ( to put it nicely) IDE I am using ( yes I use ATmel Studio too) and would like to patch it up.
It is written in Java and I have NO experience in Java because first time I was exposed to Java someone said "it does not use pointers" and the audience cheered! So I never bothered to learn Java, until now.
Hence I am looking for simple "how to do Java" book. I do not want "Java for dummies" or "click this and that and watch the screen" book with over 500 pages fat.
I studied C using K&R book and if there is such a <b>book style on Java</b> let me know.
Cheers Vaclav
|
|
|
|
|
|
Thanks Richard, looks better that K&R Ha Ha
BTW I still owe you an answer on my template problem few weeks back.
You were absolutely right, the problem was I was not looking at the rest of the parameters I have added to the original template.
It got little convoluted using both overload and several similar templates.
But it is better now, still not finished.
( I am having too much fun with too many distractions from coding, last one - I am going back to my homeland for few weeks.)
Cheeers Vaclav
|
|
|
|
|
Hi everyone,
I would be grateful if someone help me with next problem that i have in Java:
Thing that i want to do is to make client-server chat app on web. I am using RMI. I will show just important class for my problem..
Here is mu server interface:
<pre lang="java">public interface ChatServerIF extends Remote {
//void registerChatClient(ChatClientIF chatClient) throws RemoteException;
//void broadcastMessage(String message) throws RemoteException;
void registerClient(String ime, ChatClientIF chatKlijent) throws RemoteException;
void posaljiPoruku(String ime, String poruka) throws RemoteException;
void dodajWeb(String naziv, PrintWriter print) throws RemoteException;
void pronadjiWeb(String naziv) throws RemoteException;
}
server class:
public class ChatServer extends UnicastRemoteObject implements ChatServerIF {
public static final long serialVersionUID = 1L;
private HashMap<String, ChatClientIF> hmap = new HashMap<String, ChatClientIF>();
private Map<String, PrintWriter> web = new HashMap<String, PrintWriter>();
public List<HttpServletResponse> lista = new ArrayList<HttpServletResponse>();
public ChatServer() throws RemoteException{
}
@Override
public synchronized void dodajWeb(String naziv, PrintWriter print) throws RemoteException{
web.put(naziv, print);
}
@Override
public void pronadjiWeb(String naziv) throws RemoteException {
}
and part of servlet:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet IgraServlet</title>");
out.println("</head>");
out.println("<body>");
String username = request.getParameter("username");
ChatServerIF chat = (ChatServerIF) request.getSession().getAttribute("server");
ChatClient cc = (ChatClient) request.getSession().getAttribute("klijent");
PrintWriter pw = (PrintWriter) request.getSession().getAttribute("out");
chat.dodajWeb(username, pw);
cc.run();
out.println("aaa");
out.println("<h1>Servlet IgraServlet at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
}
My idea is to store user and PrintWritter for that user, from web page on server in order i can later sent message to that client.
Am i thinking good, or completely wrong?
But problem comes when i call chatServer interface method on servlet "chat.dodajWeb(username, pw)" i got next error:
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: java.io.PrintWriter
Please help me i try to search solution on internet, but for now without result..
|
|
|
|
|
plz help us to create intranet mailing system project using java and the platform is netbeans plz give us software and code for create this project.
|
|
|
|
|
Sorry no, this site does not provide code to order. Also, since it is supposed to be your project then you are expected to do the work.
|
|
|
|
|
1. Sorted Names – Write a program that asks the user to enter 10 last names (the names of every student in our class) and then displays the names sorted in ascending order. For example, if the user entered “Charlie” “Leslie” and “Andy” the program would display: Andy, Charlie, Leslie
2.. An internet service provider has 3 different packages.
A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00/hour
B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00/hour
C: For $19.95 per month unlimited access is provided
Write a program that calculates a customer’s monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A, B, or C) & the number of hours that were used. It should display the total charges
3. 3. Bank Charges: A bank charges a base fee of $10 per month, plus the following check fees for a commercial checking account.
$.10 each for less than 20 checks
$.08 each for 20-39 checks
$.06 each for 40-59 checks
$.04 each for 60+ checks
Write a program that asks for the number of checks written for the month. The program should then calculate and display the bank’s service fees for the month.
Any help with this would be greatly appreciated!
|
|
|
|
|
|
Member 12074376 wrote: Any help with this would be greatly appreciated Then you need to explain what help you want. If you are expecting someone else to write the code for you then I am afraid you are out of luck.
|
|
|
|