lab2 \& 3

This commit is contained in:
2023-01-24 20:03:45 -06:00
parent a42477e983
commit c233baa498
10 changed files with 254 additions and 1 deletions

Binary file not shown.

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.calebfontenot</groupId>
<artifactId>lab5_CalebFontenot</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<exec.mainClass>com.calebfontenot.lab5_calebfontenot.Lab5_CalebFontenot</exec.mainClass>
</properties>
</project>

View File

@@ -0,0 +1,16 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
*/
package com.calebfontenot.lab5_calebfontenot;
/**
*
* @author caleb
*/
public class Lab5_CalebFontenot {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}

View File

@@ -0,0 +1,86 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.calebfontenot.lab5_calebfontenot;
import java.util.Date;
/**
*
* @author caleb
*/
public class TrueFalseQuestion {
private String question;
private boolean isTrue;
private Date whenLastUsed;
public TrueFalseQuestion(){}
public TrueFalseQuestion(String question, boolean isTrue, Date whenLastUsed) {
this.question = question;
this.isTrue = isTrue;
this.whenLastUsed = whenLastUsed;
}
/**
* Get the value of whenLastUsed
*
* @return the value of whenLastUsed
*/
public Date getWhenLastUsed()
{
return whenLastUsed;
}
/**
* Set the value of whenLastUsed
*
* @param whenLastUsed new value of whenLastUsed
*/
public void setWhenLastUsed(Date whenLastUsed)
{
this.whenLastUsed = whenLastUsed;
}
/**
* Get the value of isTrue
*
* @return the value of isTrue
*/
public boolean isIsTrue()
{
return isTrue;
}
/**
* Set the value of isTrue
*
* @param isTrue new value of isTrue
*/
public void setIsTrue(boolean isTrue)
{
this.isTrue = isTrue;
}
/**
* Get the value of question
*
* @return the value of question
*/
public String getQuestion()
{
return question;
}
/**Sets the question to a new question.
*
* @param question the new question
*/
public void setQuestion(String question)
{
this.question = question;
}
}

View File

@@ -0,0 +1,53 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.calebfontenot.lab5_calebfontenot;
import java.util.Date;
/**
*
* @author caleb
*/
public class TrueFalseQuiz {
int currentQuestion;
TrueFalseQuestion[] trueFalseQuestions;
public TrueFalseQuiz() {
trueFalseQuestions = new TrueFalseQuestion[5];
trueFalseQuestions[0] =
new TrueFalseQuestion("The Pacific Ocean is larger than the Atlantic Ocean.",
true, new Date());
trueFalseQuestions[1] =
new TrueFalseQuestion("The Suez Canal connects the Red Sea and the Indian Ocean.", false, new Date());
trueFalseQuestions[2] =
new TrueFalseQuestion("The source of the nile River is in Egypt.", false, new Date());
trueFalseQuestions[3] =
new TrueFalseQuestion("Lake Baikal is the world\'s oldest and deepest freshwater lake.", true, new Date());
trueFalseQuestions[4] =
new TrueFalseQuestion("The Amazon River is the longest river in the Americas.", true, new Date());
this.currentQuestion = 0;
}
public TrueFalseQuiz(String[] questions, boolean[] trueFalse) {
//> Create an array of REFERENCES of size questions.length
//the references are initializesed to null
trueFalseQuestions = new TrueFalseQuestion[questions.length];
//> assign to each reference of the array an object of type TrueFalseQuestion
for(int i = 0, j = 0; i < questions.length; ++i,++j) {
trueFalseQuestions[i] = new TrueFalseQuestion(
questions[i],
trueFalse[j],
new Date());
//> set the index of the first question
this.currentQuestion = 0;
}
}
}