LD7014 Program Design and Implementation Summative Assessment.

Added on - 14 Nov 2019

  • LD7014

    course code

  • 33

    pages

  • 6326

    words

  • 146

    views

  • 0

    downloads

Showing pages 1 to 8 of 33 pages
LD7014 Program Design and Implementation Summative AssessmentStage 1: Flow Chart:CorrectYesNoYesClick Confirm ButtonStartStopStart the GameGuess the wordCheckwordFoundin TimeFound incountIncrease ScoreChoose next WordMove to Next LevelFound 5wordsLevel 3CompleteInCorrectNoNoYesYes
Stage 2: Class DiagramStage 3: GUI SketchThe GUI of the main page the user interacts and plays the game is shown below:The GUI of the settings page the user can use to change the game settings is shown below:
Stage 4: Classes in JavaWords.javaimport java.util.ArrayList;import java.util.Arrays;import java.util.Collections;import java.util.List;public abstract class Words {int level;String selectedWord;ArrayList<String> words=new ArrayList<String>();int getLevel(){return level;}void shuffle(){Collections.shuffle(words);selectedWord= words.get(0);}String getSelectedWord() {return selectedWord;}String getShuffledWord() {List<String> letters = Arrays.asList(selectedWord.split(""));Collections.shuffle(letters);
String shuffled = "";for (String letter : letters) {shuffled += letter;}return shuffled;}}Level1Words.javaimport java.util.Collections;public class Level1Words extends Words{Level1Words(){level=1;words.add("FUZZY");words.add("ACID");words.add("AREA");words.add("AGED");words.add("ZOMBI");words.add("CRAZE");words.add("GAZAR");words.add("HAZEL");words.add("ACUTE");words.add("AGREE");words.add("AFTER");words.add("ENJOY");words.add("BREAD");words.add("ABUSE");words.add("HAZE");}}Level2Words.javapublic class Level2Words extends Words{Level2Words(){level=2;words.add("BRIGHT");words.add("CAMERA");words.add("BURDEN");words.add("CENTRE");words.add("CHARGE");words.add("CHOSEN");words.add("BECOME");words.add("BEHIND");words.add("ETHNIC");words.add("EXCESS");words.add("DINNER");
words.add("DOLLAR");words.add("EASILY");words.add("EMPIRE");words.add("EXCEPT");words.add("EXCEED");words.add("AGAINST");words.add("ALCOHOL");words.add("ANOTHER");words.add("ANCIENT");}}Level3Words.javapublic class Level3Words extends Words{Level3Words(){level=3;words.add("ABSOLUTE");words.add("ACTUALLY");words.add("CARVING");words.add("CENTROIDS");words.add("CAVITATES");words.add("SCHNOZZES");words.add("JACKKNIFE");words.add("CHEAPJACK");words.add("JUKEBOXES");words.add("AIRCRAFT");words.add("ADVOCATE");words.add("DRAMATIC");words.add("DURATION");words.add("ECONOMIC");words.add("DOUBTFUL");words.add("EIGHTEEN");words.add("DRESSING");}}FindWordGUI.javaimport java.awt.Color;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;import java.util.List;import javax.swing.JOptionPane;import javax.swing.Timer;public class FindWordGUI extends javax.swing.JFrame {
int contiSuccess;int score;int time;Words word;int guessCount;/** Creates new form MainFomr */public FindWordGUI() {initComponents();score=0;contiSuccess=0;guessCount=0;time=0;word=new Level1Words();word.shuffle();repaintDisplay(word.getShuffledWord());Timer t = new Timer(1000, new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {time=time+1;timerLbl.setText("Timer: "+time+" Second");}});t.start();}/** This method is called from within the constructor to* initialize the form.* WARNING: Do NOT modify this code. The content of this method is* always regenerated by the Form Editor.*/@SuppressWarnings("unchecked")// <editor-fold defaultstate="collapsed" desc="Generated Code">private void initComponents() {jLabel14 = new javax.swing.JLabel();jLabel1 = new javax.swing.JLabel();settingsBtn = new javax.swing.JButton();jLabel2 = new javax.swing.JLabel();level1Lbl = new javax.swing.JLabel();level2Lbl = new javax.swing.JLabel();level3Lbl = new javax.swing.JLabel();
scoreLbl = new javax.swing.JLabel();exitBtn = new javax.swing.JButton();newGameBtn = new javax.swing.JButton();timerLbl = new javax.swing.JLabel();letterLbl8 = new javax.swing.JLabel();confirmBtn = new javax.swing.JButton();letterLbl7 = new javax.swing.JLabel();letterLbl1 = new javax.swing.JLabel();letterLbl6 = new javax.swing.JLabel();letterLbl2 = new javax.swing.JLabel();letterLbl4 = new javax.swing.JLabel();letterLbl5 = new javax.swing.JLabel();letterLbl3 = new javax.swing.JLabel();letterLbl9 = new javax.swing.JLabel();letterLbl10 = new javax.swing.JLabel();letterTxt1 = new javax.swing.JTextField();letterTxt3 = new javax.swing.JTextField();letterTxt4 = new javax.swing.JTextField();letterTxt5 = new javax.swing.JTextField();letterTxt2 = new javax.swing.JTextField();letterTxt8 = new javax.swing.JTextField();letterTxt9 = new javax.swing.JTextField();letterTxt10 = new javax.swing.JTextField();letterTxt7 = new javax.swing.JTextField();letterTxt6 = new javax.swing.JTextField();nextBtn = new javax.swing.JButton();statusTxt = new javax.swing.JLabel();statusLbl = new javax.swing.JLabel();clearBtn = new javax.swing.JButton();jLabel14.setText("jLabel5");setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);addWindowListener(new java.awt.event.WindowAdapter() {public void windowOpened(java.awt.event.WindowEvent evt) {formWindowOpened(evt);}});jLabel1.setFont(new java.awt.Font("Tahoma", 0, 24));jLabel1.setText("Find the Word ");settingsBtn.setText("Settings");settingsBtn.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {settingsBtnActionPerformed(evt);
}});jLabel2.setText("Level");level1Lbl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);level1Lbl.setText("1");level1Lbl.setOpaque(true);level2Lbl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);level2Lbl.setText("2");level2Lbl.setOpaque(true);level3Lbl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);level3Lbl.setText("3");level3Lbl.setOpaque(true);scoreLbl.setText("Score: 0");exitBtn.setText("Exit");exitBtn.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {exitBtnActionPerformed(evt);}});newGameBtn.setText("New Game");newGameBtn.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {newGameBtnActionPerformed(evt);}});timerLbl.setText("Timer: 0 Second");letterLbl8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);letterLbl8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0,0)));confirmBtn.setText("Confim");confirmBtn.addActionListener(new java.awt.event.ActionListener() {public void actionPerformed(java.awt.event.ActionEvent evt) {confirmBtnActionPerformed(evt);}});
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document