This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A short program using user input in an interactive loop""" | |
q = False | |
while not q: | |
user_quit = input('Quit?(y/n): ') | |
if user_quit == 'y': | |
q = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NumberOfDaysInMonth { | |
public static boolean isLeapYear(int year){ | |
boolean isLeapYear = false; | |
if (year < 1 || year > 9999){ | |
return false; | |
} | |
if (year % 4 == 0){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Point { | |
private int x; | |
private int y; | |
public Point(){ | |
//empty constructor (no argument constructor) | |
} | |
public Point(int x, int y){ | |
this.x = x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HttpUtils { | |
private static HttpServer server; | |
private static final String CLIENT_ID = "6edb9b1ac21042abacc6daaf0fbc4c4d"; | |
private static final String CLIENT_SECRET = ""; // todo: remove before committing to Github. | |
private static final String REDIRECT_ID = "http://localhost:8080"; | |
public static void startHttpServer() { | |
try { | |
server = HttpServer.create(); | |
server.bind(new InetSocketAddress(8080), 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CarsTest { | |
public static void main(String[] args) { | |
Ferrari ferrari = new Ferrari(200); | |
Jaguar jaguar = new Jaguar(190); | |
Lotus lotus = new Lotus(170); | |
Lamborghini lamborghini = new Lamborghini(210); | |
ArrayList<FastCar> fastCars = new ArrayList<>(); | |
fastCars.add(ferrari); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Collections; | |
public class Udemy { | |
public static void main(String[] args) { | |
League<FootballTeam> premierLeague = new League<>("Premier League"); | |
FootballTeam tottenham = new FootballTeam("Tottenham Hotspur",38,0, 0); | |
FootballTeam arsenal = new FootballTeam("Arsenal", 0,0, 38); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.awt.event.WindowAdapter; | |
import java.awt.event.WindowEvent; | |
public class AwtExample { | |
/*Abstract Window Toolkit Example */ | |
public static void main(String[] args) { | |
Awt window = new Awt("Test"); | |
window.setVisible(true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
JavaTeamLead javaTeamLead = new JavaTeamLead | |
(new SeniorJavaDeveloper( | |
new JavaDeveloper())); | |
System.out.println(javaTeamLead.makeJob()); | |
/* Write Java code. Make code review. Send emails to clients. */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
final Scanner scanner = new Scanner(System.in); | |
final String[] elements = scanner.nextLine().split("\\s+"); | |
int[] numbers = null; | |
if (elements[0].equals("EMPTY")) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MotorStaticFactory { | |
/** | |
* It returns an initialized motor according to the specified type by the first character: | |
* 'P' or 'p' - pneumatic, 'H' or 'h' - hydraulic, 'E' or 'e' - electric, 'W' or 'w' - warp. | |
*/ | |
public static Motor make(char type, String model, long power) { | |
type = Character.toLowerCase(type); | |
switch (type) { | |
case 'p': |
OlderNewer