dimanche 30 mars 2014

Java - While loop not functioning- Bug


Vote count:

0




I'm trying to make a "Bank Account" and that requires the user to input the name, password, balance, and interest of that bank account. I use a sentinel controlledwhile loop to achieve this, but my sentinel does not work for some reason. Here's part of my code, if you could help me that would be great:



System.out.println("New Account: Enter name, type \"quit\" to exit. ");
String name = scan.nextLine();
while (!name.equals("quit")) {
System.out.println("Enter password: ");
String pass = scan.nextLine();
System.out.println("Enter balance (in pennies): ");
double bal = scan.nextDouble();
System.out.println("Enter interest: ");
double inter = scan.nextDouble();

BankAccount2 bankacc = new BankAccount2(name, pass, bal, inter);
accounts.add(bankacc);
System.out.println("Successful account creation! New Account: Enter name, type \"quit\" to exit. ");
name = scan.nextLine();
}


asked 40 secs ago






Custom Controller Directory Structure Symfony2


Vote count:

0




I'm transitioning a Kohana application to Symfony2. In Kohana I had to register a custom autoloader to make the framework see my controllers given my preferred directory structure. Is there an elegant way in Symfony2 to achieve routing to controllers where the "Controller" directory is a level lower. For example. Src/Somename/aBundle/Theme/Frontend/Controller/defaultController.php



asked 51 secs ago






Different Window Minimize Behavior With Different Shells


Vote count:

0




I have a kiosk-style application where the user/operator can select applciations using special keys.


I have a management application that monitors the keys (via another API) and attempts to minimize and maximize other application windows as required.


For any given application, the pseudocode looks like:



foreach(var process in NotCurrentProcess())
{
IntPtr hWnd = process.MainWindowHandle;
ShowWindowAsync(hWnd, SW_FORCEMINIMIZE);
}
ShowWindowAsync(myProcess.MainWindowHandle, SW_SHOWMAXIMIZED);


This works fine for testing.


For deployment my application becomes the shell (HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon).


Now when I minimize an application, there's no taskbar for it to go to and it floats above the top window.


Floating minimized windows


Can anyone help with a root cause/fix for this?



asked 1 min ago






Using the Canvas element with the HTML 4 doctype works fine. How come?


Vote count:

0




Using the Canvas element with the HTML 4 doctype works fine in all browsers, even though Canvas is an HTML5 feature. How come? Isn't the page supposed to break if we're using the older doctype?



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://ift.tt/nYkKzf">


asked 20 secs ago






Junit - Spring - Testing Collections


Vote count:

0




Can you please advise who to test Collection with JUnit 4 and Spring MVC?


Testing a Person class can be done by:



public class TestPersonController {

@Mock
private PersonService personService;

@InjectMocks
private PersonController personController;

private MockMvc mockMvc;

@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.standaloneSetup(personController).build();
}

@Test
public void testGetPerson() throws Exception {
when(personService.getPerson(1L)).thenReturn(new Person(1L, "StackOverflow"));

mockMvc.perform(get("/person/{id}", 1L))
.andExpect(status().isOk())
.andExpect(view().name("personPage"))
.andExpect(model().attribute("personData",
allOf(hasProperty("id", is(1L)),
hasProperty("name", is("StackOverflow")))));
}
}


But I am not able to figure out how to test if perService.getPerson return List!



asked 37 secs ago






How to display html data in my app?


Vote count:

0




I am using Angular framework to populate my data in my app.


my data contains html tag


It's something like



$scope.test = <p>this is a test<?p><strong>Bold text here...</strong>


In my html



<div>
{{test}}
</div>


The output on browser show exact text '<p>this is a test</p> <strong>Bold text here...</strong>'. I want it to parse html tag and show'


this is a test


Bold text here....

Is that possible?


Thanks a lot!



asked 41 secs ago






Quicksort Infinite Loop Issue in C++


Vote count:

0




I have extensively tested the swap and partition function for the following code and they appear to be correct; however, when I try to execute quicksort it goes into an infinite loop. I'm assuming the issue happens from my returned value in partition, but I am not entirely sure what it is.



void swap_G(int *begin, int *end)
{
int temp = *begin;
*begin = *end;
*end = temp;
return;
}

int* partition(int* begin, int* end)
{
if (begin >= end) {
return begin;
}

int pivot = *end;
int* temp_Begin = begin, *temp_End = end;
temp_End--;

while (temp_Begin < temp_End)
{
while (*temp_Begin < pivot && temp_Begin < temp_End)
{
temp_Begin++;
}
while (*temp_End > pivot && temp_End > temp_Begin)
{
temp_End--;
}
swap_G(temp_Begin, temp_End);
}
swap_G(end, temp_Begin);
return temp_Begin;
}

void quicksort_G(int* begin, int* end)
{
if (begin >= end)
{
return;
}
int* mid = partition(begin, end);
quicksort_G(begin, --mid);
quicksort_G(mid + 1, end);
}


asked 27 secs ago