Paste what's on your clipboard thread


Recommended Posts


package domainmodel;
/**
* De klasse kaart stelt een kaart voor van een bepaald type
* (Harten/Klaveren/Ruiten/Schoppen) en een bepaald nummer (1-13, waar 1 = Aas,
* 11 = Boer, 12 = Dame, 13 = Koning)
*
* @author Ambroos
*
*/
/**
* @author Ambroos
*
*/
public class Kaart {
private String type = "Harten";
private int nummer = 1;
private boolean omgedraaid = true;
/**
* Maakt een nieuwe kaart aan met een bepaald type en een bepaald nummer.
*
* @param type
* Het type van de kaart, moet Harten/Klaveren/Ruiten/Schoppen
* zijn.
* @param nummer
* Het nummer van de kaart, moet 1-13 zijn. (1 = Aas, 11 = Boer,
* 12 = Dame, 13 = Koning)
* @throws IllegalArgumentException
* Wanneer het type of het nummer van de kaart ongeldig is.
*/
public Kaart(String type, int nummer) throws IllegalArgumentException {
this.setType(type);
this.setNummer(nummer);
}
private void setType(String type) throws IllegalArgumentException {
if (type == null)
throw new IllegalArgumentException("Type mag niet null zijn.");
if (!(type.equals("Harten") || type.equals("Ruiten")
|| type.equals("Schoppen") || type.equals("Klaveren")))
throw new IllegalArgumentException(
"Kaarttype moet Harten, Koeken, Schoppen of Klaveren zijn. Hoofdlettergevoelig.");
this.type = type;
}
/**
* Geeft het type van de kaart. (Harten/Klaveren/Ruiten/Schoppen)
*
* @return Het type van de kaart.
*/
public String getType() {
return type;
}
private void setNummer(int nummer) throws IllegalArgumentException {
if (nummer < 1 || nummer > 13)
throw new IllegalArgumentException(
"Kaartnummer moet tussen 1 en 13 liggen.\n11 = Boer\n12 = Dame\n13 = Koning");
this.nummer = nummer;
}
/**
* Geeft het nummer van de kaart. 1 = Aas, 11 = Boer, 12 = Dame, 13 =
* Koning.
*
* @return Het nummer van de kaart;
*/
public int getNummer() {
return nummer;
}
/**
* Draait de kaart om. Omgedraaide kaarten worden ont-omgedraaid. Ofzo.
*/
public void draaiOm() {
setOmgedraaid(!isOmgedraaid());
}
private void setOmgedraaid(boolean isOmgedraaid) {
this.omgedraaid = isOmgedraaid;
}
/**
* Geeft terug of de kaart is omgedraaid.
*
* @return True wanneer de kaart is omgedraaid.
*/
public boolean isOmgedraaid() {
return omgedraaid;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
String result = null;
String teken = "" + getNummer();
if (nummer == 1) {
teken = "Aas";
} else if (nummer == 11) {
teken = "Boer";
} else if (nummer == 12) {
teken = "Dame";
} else if (nummer == 13) {
teken = "Koning";
}
if (isOmgedraaid()) {
result = getType() + " " + teken;
} else {
result = "--";
}
return result;
}
/**
* Kijkt of een kaart op gebied van nummer en type gelijk is aan een andere
* kaart. Of de kaarten dezelfde omdraaistatus hebben maakt niet uit.
*
* @param kaart
* De kaart om te vergelijken met de oproepende kaart.
* @return True wanneer beide kaarten hetzelfde type en hetzelfde nummer
* hebben.
*/
public boolean equals(Object o) {
boolean result = false;
if (o != null && o instanceof Kaart) {
Kaart kaart = (Kaart) o;
if (kaart.getNummer() == this.getNummer()
&& kaart.getType().equals(this.getType()))
result = true;
}
return result;
}
/**
* Interprets human input (such as "hartenaas" or "klaverenboer" or
* "Harten tien" and almost all other possible valid inputs to return the
* right card and maximize usability.
*
* @param input
* any string input that might contain enough information to form
* a card
* @return the card the user put in
* @throws IllegalArgumentException
* when the input could not be interpreted properly or was
* invalid
*/
public static Kaart humanInput(String input)
throws IllegalArgumentException {
int nummer = 0;
String type = null;
if (input == null || input.length() == 0) {
throw new IllegalArgumentException("De invoer is ongeldig.");
}
input = input.toLowerCase();
// Check all possible number inputs.
if (input.contains("1") || input.contains("een")
|| input.contains("aas"))
nummer = 1;
if (input.contains("2") || input.contains("twee"))
nummer = 2;
if (input.contains("3") || input.contains("drie"))
nummer = 3;
if (input.contains("4") || input.contains("vier"))
nummer = 4;
if (input.contains("5") || input.contains("vijf"))
nummer = 5;
if (input.contains("6") || input.contains("zes"))
nummer = 6;
if (input.contains("7") || input.contains("zeven"))
nummer = 7;
if (input.contains("8") || input.contains("acht"))
nummer = 8;
if (input.contains("9") || input.contains("negen"))
nummer = 9;
if (input.contains("10") || input.contains("tien"))
nummer = 10;
if (input.contains("boer") || input.contains("11"))
nummer = 11;
if (input.contains("dame") || input.contains("koningin")
|| input.contains("12"))
nummer = 12;
if (input.contains("koning") || input.contains("heer")
|| input.contains("13"))
nummer = 13;
// Check all possible type inputs
if (input.contains("hart")) {
type = "Harten";
}
if (input.contains("klaver")) {
type = "Klaveren";
}
if (input.contains("schop") || input.contains("schup")) {
type = "Schoppen";
}
if (input.contains("ruit") || input.contains("koek")) {
type = "Ruiten";
}
if (nummer == 0 || type == null)
throw new IllegalArgumentException("De invoer is ongeldig.");
return new Kaart(type, nummer);
}
/**
* Vergelijkt twee kaarten op gebied van nummer, type en eventueel null of
* niet. Deze methode kan gebruikt worden bij het sorteren. De
* vergelijkingsvolgorde is de standaardvolgorde van de kaarten.
* (Aas-2...10-Boer-Dame-Koning, Harten/Klaveren/Ruiten/Schoppen)
*
* @param kaart
* De kaart om mee te vergelijken.
* @return Een positief cijfer als de oproepende kaart juist staat tegenover
* de parameterkaart.
*/
public int compareTo(Kaart kaart) {
int verschil = 0;
if (kaart == null) {
verschil = -1;
} else {
verschil = getType().compareTo(kaart.getType());
}
if (verschil == 0) {
verschil = getNummer() - kaart.getNummer();
}
return verschil;
}
}
[/CODE]

You asked for it...

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Same Internet Archive seemed to grab the new version https://web.archive.org/web/20...d/Setup_MakeMKV_v1.18.4.exe Here's the link to an additional file it periodically downloads https://web.archive.org/web/20260213092148/https://www.makemkv.com/sdf.bin I think update's keys, etc. To manually trigger this update, put the sdf.bin file in the root of where the program is installed. When you launch the program it will pick up the file and import it. Typically put it here: C:\Program Files (x86)\MakeMKV\sdf.bin
    • Windows 11 KB5094126, KB5093998 bugging out Office apps but it may not be Microsoft's fault by Sayan Sen Microsoft last week released Windows 11 KB5094126 and KB5093998 as the latest Patch Tuesday updates. Following that the company also published the accompanying dynamic updates under KB5094149, KB5095971, and KB5094156. Although the tech giant did not acknowledge any major problems, some users online reported various issues ranging from OneDrive and Dropbox access problems, BitLocker recovery lockouts, to blue screens and BSODs. You can read about them in this dedicated piece. While there is still no confirmation about those problems from Microsoft the company has admitted to another bug which we did not report on. The tech giant has confirmed it has received reports of an issue in which certain third-party applications may be unable to launch Microsoft Office apps or open Office documents after installing the Patch Tuesday. This affects both Windows 11 as well as Windows 10. The company says the problem impacts a subset of applications that rely on OLE (Object Linking and Embedding) automation to communicate with Microsoft Office programs. According to Microsoft, affected scenarios involve third-party software attempting to open Office applications or documents from within their own interface. In such cases, the Office program may fail to launch altogether, or the requested document may not open. Oddly there may not be any error message, which probably makes the issue difficult to diagnose. The bug affects several Office products, including Word, Excel, PowerPoint, Access, and other apps in the Microsoft Office suite when they are launched through the affected software. These include tax and accounting software such as CCH Engagement and Workpaper Manager, dental practice management solutions like Dentrix and Softdent, as well as the popular research and reference management tool Zotero. Microsoft adds that other applications using similar Office integration methods could also experience the same problematic behavior. To understand the issue it is important to look at OLE, the Microsoft technology involved. OLE allows different applications to work together and share data, while its Automation feature lets one program control another. Thus this enables third-party software to launch Microsoft Office apps, open documents, and perform tasks automatically without requiring users to switch between programs. Because many accounting, healthcare, research, and business applications rely on OLE automation to interact with Word, Excel, PowerPoint, and other Office apps, any disruption can break those workflows. As a result, affected software may be unable to open Office documents or launch Office applications even though the programs themselves continue to work normally. At the moment the company has not provided a permanent fix though it has confirmed that engineers are actively working on a resolution, which will be delivered through a future Windows update. As such additional details will be shared once more information becomes available. In the meantime, Microsoft recommends a simple workaround for affected users whic is to open the Office application or document directly rather than launching it through the third-party program. For enterprise customers and organizations managing larger deployments, Microsoft says an additional mitigation is available. Admins experiencing the problem on their managed devices are advised to contact Microsoft Support for business to obtain and apply the workaround.
    • It saddens me when cars are such dull colours now. Mine is bright metallic blue and I absolutely adore it for standing out in contrast to that depressing backdrop of traffic.
    • Sparkle 2.20.0 by Razvan Serea Sparkle is a free, open-source Windows optimization tool designed to make your PC faster, cleaner, and more private. With Sparkle, you can easily debloat Windows by removing unnecessary apps and services, disable Microsoft tracking to enhance privacy, and apply performance tweaks to boost speed. Its cleaner removes junk and temporary files, while every change is safe and fully reversible. Sparkle also features a modern, user-friendly interface with automatic updates, making system maintenance simple. Explore over 39 tweaks, from disabling telemetry and hibernation to optimizing network and game settings, all aimed at customizing and enhancing your Windows experience. Sparkle supports Windows 10 and 11. Sparkle 2.20.0 changelog: Debloat Tweak has animated border New homepage loading UI New Tweak Modal (Markdown Supported) Refactored GPU Detection Added Tests with vitest Added foobar2000 to apps Added Localsend to apps Updated Modal Styles Added styles for disabled inputs Added Animated Border to debloat-windows tweak Bumped dependencies Refactor System info logic for speed Tweak info modals now support Markdown Added Clear System info cache to settings Redesigned Home Page Loading UI Changed Some Icons around the app Download: Sparkle 2.20.0 | Portable | ~100.0 MB (Open Source) Links: Sparkle Website | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • lol it was a typo, fixed! haha imagine an actual 4TB Gen4 NVMe for $40 in 2026
  • Recent Achievements

    • Reacting Well
      Dys Topia earned a badge
      Reacting Well
    • Conversation Starter
      NovaEdgeX earned a badge
      Conversation Starter
    • One Year In
      Console General earned a badge
      One Year In
    • Week One Done
      Twozo Technologies earned a badge
      Week One Done
    • One Month Later
      Twozo Technologies earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      517
    2. 2
      +Edouard
      184
    3. 3
      PsYcHoKiLLa
      106
    4. 4
      Steven P.
      88
    5. 5
      ATLien_0
      68
  • Tell a friend

    Love Neowin? Tell a friend!