we have been given a scenario to design a system in which we have to make the class diasgrams. however we have to use appropriate patterns that match the scenario.
I've looked over the concepts of Java programming, tested them in code and i understand most of them. I have a problem when i need to make harder programs , this might be because i dont know design patterns and algorithms.I'm curious what a entry level programmer needs to know to get a job in the field. Right now i was thinking i need to know:
1. The way all big concepts work and most of the keywords.
2. Design patterns.
3. Algorithms.
what i actually need to know for an entry level job and can you tell me which design patterns and algorithms are a must know for that first job. Considering i might have financial problems in the near future this is not a theoretical question, i really need to know what i need to learn in the next 2-3 months to get an entry level job down.
My assignment was to create a simple form that demonstrates the use of the factory and singleton design patterns. "Use the Factory pattern to ensure that each form input consists of a text label and a textfield. Use the Singleton pattern for the submit button. When the submit button is clicked, a pop-up should show all the information that was typed into all of the form fields."
I used JFrame to create the form without the design patterns and I although I get the desired result, I'm not quite sure how I can integrate the design patterns into the code I wrote. The example I have to go off uses shapes, not text fields so I think that's why I'm not quite clear on how to approach this.
My assignment was to create a simple form that demonstrates the use of the factory and singleton design patterns. "Use the Factory pattern to ensure that each form input consists of a text label and a textfield. Use the Singleton pattern for the submit button."
Here's what I have:
Form.java file
interface Form { public void getFormField (); } Name.java file (I have a similar files just like this for Address.java, City.java, State.java, Zip.java and Phone.java) import java.util.Scanner; class Name implements Form
[Code] ....
It compiles at the moment but I get a null pointer exception in the main method of the FormFactoryDemo file.
public class BankAccount { String name; int accountID; double balance; } public void setAcct ( String nam, double acctID)
[Code] ....
1. Create a class called BankAccount a. It will be a generic simple type of BankAccount
2. BankAccount will contain variables to store: a. the owner/owners of the account b. an account id c. it may contain other basic information (up to you)
3. BankAccount will contain methods that will allow you to: a. Set the account owners information b. Deposit money c. Withdraw money d. Set balances e. Print out transactions (think more like an atm each time an action is taken it gets printed)
4. BankAccount will contain its own main() a. At least 2 BankAccount objects will be created and ALL of their methods called .
Budget program. Here is my situation, I have 2 tabs in a GUI, one tab adds a transactions when the add button is clicked, and in the other tab displays a table showing all the transactions. In my code, I want it so that when the user chooses a deposit(combo box variable name = cbType, indexnumber for deposit is 0) it will add to the total and when the user chooses withdraw(index number is 1) then it will subtract it from the total. Here is the code.... (note as well, the code also adds a new row to the table)
So when I tested the program with 2 transactions, the first transaction was a deposit and the 2nd transaction was a withdraw. The end product was that both amounts were subtracted from the total. When I did a withdraw first and a deposit second, the amounts were both added together.
I want to get current Computer CPU usage of my computer and display it in Console View of Eclipse? How can I achieve this?
My template code is:
Java Code: public class GetCPUUsage{ public static void main(String[] args){ System.out.println("CPU USAGE IS: ??????"); } } mh_sh_highlight_all('java');
I added ??? as placeholder for CPU usage because I do not know how to retrieve RAM usage by Java.
I created an instant messenger using java. When I have the Server that communicates between the clients and one client running on my Computer the CPU Usage is at 100%. It really slows down everything else I'm doing and I figure this might be an issue if I gave this to people to use. I don't want the client taking up a lot of CPU Usage if they're just running it in the background while doing other things on their computer. The program utilizes multithreading. Each thread is constantly being polled for input.
The Server, as seen below, has two threads. I explain what the threads do before the code. There is also another while loop running constantly in the server that is waiting for sockets to connect. The loop does not run constantly at the line socket.accept(); it stops and just waits.
The User, split into a menu and chat window, has two threads as well. I explain what the threads do before the code. After I originally posted I put a 100 ms sleep in all my threads. CPU Usage is still at 100%*
This thread listens for input from the user. The input tells the server what action to take. There is a thread running for every user currently connected to the server.
public void run() { try { input = new DataInputStream(user.getSocket().getInputStream()); output = new DataOutputStream(user.getSocket().getOutputStream());
I would like to limit my bandwidth usage when accessing/downloading files (similar to the --limit-rate 50K option for curl and wget) as the website has limited bandwidth. I am not exactly sure how to implement this, but I'm guessing it be accomplished via the BufferedReader? I have attached the current code below.
My question is regarding the the Inversion of Control (IoC) and Dependency Injection (DI) patterns, when learning about Spring i saw that people keep talking about Ioc and Dependecy Injection like if its the same thing!
I wrote this (for the variable name, this is just a small part of my program and I'm trying to get the pattern right so I didn't mind my variables at the moment):
Java Code:
public class NewFile{ public static void main(String []args){ int k = 0; for (int i=1 ; i<=5 ; i++) { { for (int h=2 ; h >= i ; h--)
I realize I should divide the code into a lower and upper triangle using two loops. However, I don't know how to break the first part. I did find the "trend" but I don't see how to implement it.
I need to make a program that does stripes, checkerboard, and double diagonal. I can not get the stripes to work?
import java.util.Scanner; public class AsciiArt { public static void main(String[] args){ int pattern; Scanner input=new Scanner(System.in); System.out.println("Choose one of the following patterns by pressing the corresponding number"); System.out.println("1) Stripes");
Declaring the method as static precludes one from using any sort of object oriented programming, thus the method cannot access instance fields of the object if it needs to.
I created two short classes to sort of find out what this meant, but I feel I do not understand it well enough.
Test class (main):
package votek; public class Test { public static void main(String[] args) { SomeMethod(); } public static void SomeMethod() { Character character = new Character(); character.totalLevel = 50; System.out.println(character.totalLevel); } }
Character class:
package votek; public class Character { private int level = 0; public Character() { level = 50; } }
OR
Does it mean that making a static method in the class with private instances will prevent the method from using the private instances?
I've spent almost 3 hours on googling about java beans and where it is usable. What I've figured out is that a bean has a public non-arg constructor, properties and getters/setters to manipulate them. I also know that a bean contains no logic, only fields. However, I don't fully understand why I need to use beans instead of normal classes even if a class can do the same things like a bean? Are beans used to store data or what?
We have a webservices application that uses Java 1.6.0_43, Spring 3.2.3, CXF 2.6.9 and deployed to Jboss 5.0.1 GA in a LINUX x86_64 centos box. It essentially uses apache httpclient (4.2.2) to call internal services and returns the results back to customers. The application has been running fine for a year or so until early this month when all of sudden, it loaded about 300K classes in a very short time during our regression tests and saturated the CPU usage ever since. Hence the application is no longer responding.
I have been trying to troubleshoot the problem for a while. Tried visualvm, dynatrace. thread dumps. heap dumps... None of them is very effective in capturing what are the classes that are loaded so many times and what path triggered that.
I am just learning how to throw exceptions, and I'm stuck on the last part,
Here is where I created the exception that receives a string consisting of ID and wage.
public class EmployeeException extends Exception { public EmployeeException(String Employee) { super(Employee); } }
Here is where I created the Employee class with the two fields. I also believe I am throwing the exception if the hourly wage is < $6 or > $50.
public class Employee { int idNum; double hourlyWage; public void Employee(int empID, double empWage) throws EmployeeException { idNum = empID; hourlyWage = empWage;
[Code]...
Now, I need to write an application with three employees and display a message when an employee is successfully created or not. This is what I have so far... I'm trying to get it to work with one employee, and then I can easily go back and add two more.
import javax.swing.*; public class ThrowEmployee { public static void main (String[] args) { try { Employee one = new Employee(542, 15.20); }
[Code
The current compile error that I'm receiving is: ThrowEmployee.java:12: error: constructor Employee in class Employee cannot be applied to given types;
Employee one = new Employee(542, 15.20); ^ required: no arguments found: int,double reason: actual and formal argument lists differ in length 1 error
I have public void Employee(int empID, double empWage) in my Employee class, so why is it saying that no arguments are required? Not sure if I'm missing a step with throwing exceptions, because this error has always been a simple fix when I've come across it in the past?!?
In my EJB modules, to prevent that any JPA exception is ever thrown, I check the condition that would cause the exception beforehand. For example, the exception javax.persistence.EntityExistsException is never thrown because, before persisting the entity, I check if such primary key already exists in the DB. Is it the right way to do this?
Another approach is too allow the JPA exceptions to be thrown and catch them in a try-catch block, and then throw my custom exception from the "catch" block. However it requires to call EntityManager.flush () at the end of the "try" block. Otherwise the exception throw could be deferred and never be caught by my block.