added old projects
This commit is contained in:
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
QuadraticSolver quadSolve = new QuadraticSolver(1, 2, 3);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
public class NonRealException extends QuadraticException
|
||||
{
|
||||
public NonRealException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
public class QuadraticException extends ArithmeticException
|
||||
{
|
||||
public QuadraticException(String msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
public class QuadraticSolver {
|
||||
|
||||
private int _a;
|
||||
private int _b;
|
||||
private int _c;
|
||||
|
||||
public QuadraticSolver() {
|
||||
_a = 1;
|
||||
_b = 1;
|
||||
_c = 1;
|
||||
}
|
||||
|
||||
public QuadraticSolver(int a, int b, int c) throws QuadraticException
|
||||
{
|
||||
if (a == 0)
|
||||
throw new QuadraticException("Not a real quadratic");
|
||||
|
||||
_a = a;
|
||||
_b = b;
|
||||
_c = c;
|
||||
|
||||
}
|
||||
|
||||
public double discriminant() {
|
||||
return _b*_b - 4 * _a * _c;
|
||||
}
|
||||
|
||||
public boolean realSolution() {
|
||||
return discriminant() >= 0 ;
|
||||
}
|
||||
|
||||
public double firstRoot() throws NonRealException {
|
||||
if (!realSolution())
|
||||
throw new NonRealException("no real solution");
|
||||
return (-1 * _b + discriminant()) / (2 * _a);
|
||||
}
|
||||
|
||||
public double secondRoot() throws NonRealException{
|
||||
if (!realSolution())
|
||||
throw new NonRealException("no real solution");
|
||||
else
|
||||
return (-1 * _b - discriminant()) / (2 * _a);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "f(x) = " + _a + "x^2 + " + _b + "x + " + _c;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user