Compare commits
1 Commits
8dd6533d47
...
hw3
| Author | SHA1 | Date | |
|---|---|---|---|
|
041d85b85d
|
@@ -1,7 +1,3 @@
|
|||||||
package iterator;
|
|
||||||
|
|
||||||
import model.Photo;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
package model;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,8 +1,3 @@
|
|||||||
import controller.PhotoAlbumController;
|
|
||||||
import model.PhotoAlbumModel;
|
|
||||||
import view.PhotoAlbumView;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Photo Album Manager application entry point.
|
* Photo Album Manager application entry point.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -1,12 +1,3 @@
|
|||||||
package controller;
|
|
||||||
|
|
||||||
import model.Photo;
|
|
||||||
import model.PhotoAlbumModel;
|
|
||||||
import strategy.SortByDate;
|
|
||||||
import strategy.SortByName;
|
|
||||||
import strategy.SortBySize;
|
|
||||||
import view.PhotoAlbumView;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -1,9 +1,3 @@
|
|||||||
package model;
|
|
||||||
|
|
||||||
import strategy.SortingStrategy;
|
|
||||||
import iterator.AlbumIterator;
|
|
||||||
import iterator.PhotoIterator;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,9 +1,3 @@
|
|||||||
package view;
|
|
||||||
|
|
||||||
import controller.PhotoAlbumController;
|
|
||||||
import model.Photo;
|
|
||||||
import model.PhotoAlbumModel;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
package iterator;
|
|
||||||
|
|
||||||
import model.Photo;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
package strategy;
|
|
||||||
|
|
||||||
import model.Photo;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
package strategy;
|
|
||||||
|
|
||||||
import model.Photo;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -1,7 +1,3 @@
|
|||||||
package strategy;
|
|
||||||
|
|
||||||
import model.Photo;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
package strategy;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
29
hw4/.gitignore
vendored
29
hw4/.gitignore
vendored
@@ -1,29 +0,0 @@
|
|||||||
### IntelliJ IDEA ###
|
|
||||||
out/
|
|
||||||
!**/src/main/**/out/
|
|
||||||
!**/src/test/**/out/
|
|
||||||
|
|
||||||
### Eclipse ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
bin/
|
|
||||||
!**/src/main/**/bin/
|
|
||||||
!**/src/test/**/bin/
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
### Mac OS ###
|
|
||||||
.DS_Store
|
|
||||||
8
hw4/.idea/.gitignore
generated
vendored
8
hw4/.idea/.gitignore
generated
vendored
@@ -1,8 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
5
hw4/.idea/codeStyles/codeStyleConfig.xml
generated
5
hw4/.idea/codeStyles/codeStyleConfig.xml
generated
@@ -1,5 +0,0 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<state>
|
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
|
||||||
</state>
|
|
||||||
</component>
|
|
||||||
6
hw4/.idea/inspectionProfiles/Project_Default.xml
generated
6
hw4/.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<profile version="1.0">
|
|
||||||
<option name="myName" value="Project Default" />
|
|
||||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
||||||
6
hw4/.idea/misc.xml
generated
6
hw4/.idea/misc.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
8
hw4/.idea/modules.xml
generated
8
hw4/.idea/modules.xml
generated
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/hw4.iml" filepath="$PROJECT_DIR$/hw4.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
6
hw4/.idea/vcs.xml
generated
6
hw4/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
# Programming Assignment 4 - Shape Displayer
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
The user interacts with the application as follows:
|
|
||||||
|
|
||||||
- Initially, the program displays three buttons on the top of the frame and a
|
|
||||||
blank large area of a user-defined JPanel below the buttons. The buttons
|
|
||||||
display a car, a snow man, and a composite shape of your choice, respectively.
|
|
||||||
You are allowed to borrow the CarShape.java from the text book. Make sure to
|
|
||||||
acknowledge that the code is from the text book. The composite shape of your
|
|
||||||
choice should consist of at least 4 primitive shapes, but doesn't have to be
|
|
||||||
fancy.
|
|
||||||
- When the user clicks on one of the buttons, the shape displayed on the clicked
|
|
||||||
button becomes the current shape. The icon representing the current shape
|
|
||||||
should outline the shape as shown below in the sample output. When a mouse is
|
|
||||||
clicked on the user-defined JPanel, the current shape is drawn on the position
|
|
||||||
which the mouse was pressed on.
|
|
||||||
- The current shape can be changed by clicking one of the buttons.
|
|
||||||
- The application should be reusable by any CompositeShape.
|
|
||||||
- Your design should be object-oriented including ShapeDisplayer(with main
|
|
||||||
method), CarShape, SnowMan, and Your_own_shape classes. Also, it should
|
|
||||||
include interface CompositeShape.java and a concrete class ShapeIcon. You may
|
|
||||||
include more classes to your design.
|
|
||||||
11
hw4/hw4.iml
11
hw4/hw4.iml
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.geom.Rectangle2D;
|
|
||||||
|
|
||||||
public class ShapeDisplayer {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// Create and configure the main frame on the Event Dispatch Thread
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
JFrame frame = new JFrame("Mancala");
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.setSize(800, 400);
|
|
||||||
|
|
||||||
// Create buttons panel
|
|
||||||
JPanel buttonPanel = new JPanel();
|
|
||||||
buttonPanel.setLayout(new FlowLayout());
|
|
||||||
|
|
||||||
// Create placeholder shapes
|
|
||||||
JButton carButton = new JButton(new PlaceholderIcon(Color.RED));
|
|
||||||
JButton snowmanButton = new JButton(new PlaceholderIcon(Color.BLUE));
|
|
||||||
JButton compositeButton = new JButton(new PlaceholderIcon(Color.GREEN));
|
|
||||||
|
|
||||||
|
|
||||||
// Add buttons to the panel
|
|
||||||
buttonPanel.add(carButton);
|
|
||||||
buttonPanel.add(snowmanButton);
|
|
||||||
buttonPanel.add(compositeButton);
|
|
||||||
|
|
||||||
// Add buttons panel to the top of the frame
|
|
||||||
frame.add(buttonPanel, BorderLayout.NORTH);
|
|
||||||
|
|
||||||
// Add drawing panel
|
|
||||||
JPanel drawingPanel = new JPanel();
|
|
||||||
drawingPanel.setBackground(Color.WHITE);
|
|
||||||
frame.add(drawingPanel, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
// Center the frame on the screen and make it visible
|
|
||||||
frame.setLocationRelativeTo(null);
|
|
||||||
frame.setVisible(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PlaceholderIcon implements Icon {
|
|
||||||
private final Color color;
|
|
||||||
private static final int WIDTH = 60;
|
|
||||||
private static final int HEIGHT = 40;
|
|
||||||
|
|
||||||
public PlaceholderIcon(Color color) {
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
|
||||||
Rectangle2D.Double rect = new Rectangle2D.Double(x + 5, y + 5, WIDTH - 10, HEIGHT - 10);
|
|
||||||
g2.setColor(color);
|
|
||||||
g2.fill(rect);
|
|
||||||
g2.setColor(Color.BLACK);
|
|
||||||
g2.draw(rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getIconWidth() {
|
|
||||||
return WIDTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getIconHeight() {
|
|
||||||
return HEIGHT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user